mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Merge 201b13a20a
into cc2af329d0
This commit is contained in:
commit
9c526573ea
189 changed files with 11800 additions and 11946 deletions
199
.clang-format
Normal file
199
.clang-format
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
# Commented out parameters are those with the same value as base LLVM style.
|
||||||
|
# We can uncomment them if we want to change their value, or enforce the
|
||||||
|
# chosen value in case the base style changes (last sync: Clang 14.0).
|
||||||
|
---
|
||||||
|
### General config, applies to all languages ###
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
# AlignArrayOfStructures: None
|
||||||
|
# AlignConsecutiveMacros: None
|
||||||
|
# AlignConsecutiveAssignments: None
|
||||||
|
# AlignConsecutiveBitFields: None
|
||||||
|
# AlignConsecutiveDeclarations: None
|
||||||
|
# AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments: false
|
||||||
|
# AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
# AllowShortEnumsOnASingleLine: true
|
||||||
|
# AllowShortBlocksOnASingleLine: Never
|
||||||
|
# AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
# AllowShortFunctionsOnASingleLine: All
|
||||||
|
# AllowShortLambdasOnASingleLine: All
|
||||||
|
# AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
# AllowShortLoopsOnASingleLine: false
|
||||||
|
# AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
# AlwaysBreakAfterReturnType: None
|
||||||
|
# AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
# AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
# AttributeMacros:
|
||||||
|
# - __capability
|
||||||
|
# BinPackArguments: true
|
||||||
|
# BinPackParameters: true
|
||||||
|
# BraceWrapping:
|
||||||
|
# AfterCaseLabel: false
|
||||||
|
# AfterClass: false
|
||||||
|
# AfterControlStatement: Never
|
||||||
|
# AfterEnum: false
|
||||||
|
# AfterFunction: false
|
||||||
|
# AfterNamespace: false
|
||||||
|
# AfterObjCDeclaration: false
|
||||||
|
# AfterStruct: false
|
||||||
|
# AfterUnion: false
|
||||||
|
# AfterExternBlock: false
|
||||||
|
# BeforeCatch: false
|
||||||
|
# BeforeElse: false
|
||||||
|
# BeforeLambdaBody: false
|
||||||
|
# BeforeWhile: false
|
||||||
|
# IndentBraces: false
|
||||||
|
# SplitEmptyFunction: true
|
||||||
|
# SplitEmptyRecord: true
|
||||||
|
# SplitEmptyNamespace: true
|
||||||
|
# BreakBeforeBinaryOperators: None
|
||||||
|
# BreakBeforeConceptDeclarations: true
|
||||||
|
# BreakBeforeBraces: Attach
|
||||||
|
# BreakBeforeInheritanceComma: false
|
||||||
|
# BreakInheritanceList: BeforeColon
|
||||||
|
# BreakBeforeTernaryOperators: true
|
||||||
|
# BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
# BreakStringLiterals: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
# CommentPragmas: '^ IWYU pragma:'
|
||||||
|
# QualifierAlignment: Leave
|
||||||
|
# CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
# DeriveLineEnding: true
|
||||||
|
# DerivePointerAlignment: false
|
||||||
|
# DisableFormat: false
|
||||||
|
# EmptyLineAfterAccessModifier: Never
|
||||||
|
# EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
# ExperimentalAutoDetectBinPacking: false
|
||||||
|
# PackConstructorInitializers: BinPack
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
# AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
# FixNamespaceComments: true
|
||||||
|
# ForEachMacros:
|
||||||
|
# - foreach
|
||||||
|
# - Q_FOREACH
|
||||||
|
# - BOOST_FOREACH
|
||||||
|
# IfMacros:
|
||||||
|
# - KJ_IF_MAYBE
|
||||||
|
# IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '".*"'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 3
|
||||||
|
# IncludeIsMainRegex: '(Test)?$'
|
||||||
|
# IncludeIsMainSourceRegex: ''
|
||||||
|
# IndentAccessModifiers: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
# IndentCaseBlocks: false
|
||||||
|
# IndentGotoLabels: true
|
||||||
|
# IndentPPDirectives: None
|
||||||
|
# IndentExternBlock: AfterExternBlock
|
||||||
|
# IndentRequires: false
|
||||||
|
IndentWidth: 4
|
||||||
|
# IndentWrappedFunctionNames: false
|
||||||
|
# InsertTrailingCommas: None
|
||||||
|
# JavaScriptQuotes: Leave
|
||||||
|
# JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
# LambdaBodyIndentation: Signature
|
||||||
|
# MacroBlockBegin: ''
|
||||||
|
# MacroBlockEnd: ''
|
||||||
|
# MaxEmptyLinesToKeep: 1
|
||||||
|
# NamespaceIndentation: None
|
||||||
|
# PenaltyBreakAssignment: 2
|
||||||
|
# PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
# PenaltyBreakComment: 300
|
||||||
|
# PenaltyBreakFirstLessLess: 120
|
||||||
|
# PenaltyBreakOpenParenthesis: 0
|
||||||
|
# PenaltyBreakString: 1000
|
||||||
|
# PenaltyBreakTemplateDeclaration: 10
|
||||||
|
# PenaltyExcessCharacter: 1000000
|
||||||
|
# PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
# PenaltyIndentedWhitespace: 0
|
||||||
|
# PointerAlignment: Right
|
||||||
|
# PPIndentWidth: -1
|
||||||
|
# ReferenceAlignment: Pointer
|
||||||
|
# ReflowComments: true
|
||||||
|
# RemoveBracesLLVM: false
|
||||||
|
# SeparateDefinitionBlocks: Leave
|
||||||
|
# ShortNamespaceLines: 1
|
||||||
|
# SortIncludes: CaseSensitive
|
||||||
|
# SortJavaStaticImport: Before
|
||||||
|
# SortUsingDeclarations: true
|
||||||
|
# SpaceAfterCStyleCast: false
|
||||||
|
# SpaceAfterLogicalNot: false
|
||||||
|
# SpaceAfterTemplateKeyword: true
|
||||||
|
# SpaceBeforeAssignmentOperators: true
|
||||||
|
# SpaceBeforeCaseColon: false
|
||||||
|
# SpaceBeforeCpp11BracedList: false
|
||||||
|
# SpaceBeforeCtorInitializerColon: true
|
||||||
|
# SpaceBeforeInheritanceColon: true
|
||||||
|
# SpaceBeforeParens: ControlStatements
|
||||||
|
# SpaceBeforeParensOptions:
|
||||||
|
# AfterControlStatements: true
|
||||||
|
# AfterForeachMacros: true
|
||||||
|
# AfterFunctionDefinitionName: false
|
||||||
|
# AfterFunctionDeclarationName: false
|
||||||
|
# AfterIfMacros: true
|
||||||
|
# AfterOverloadedOperator: false
|
||||||
|
# BeforeNonEmptyParentheses: false
|
||||||
|
# SpaceAroundPointerQualifiers: Default
|
||||||
|
# SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
# SpaceInEmptyBlock: false
|
||||||
|
# SpaceInEmptyParentheses: false
|
||||||
|
# SpacesBeforeTrailingComments: 1
|
||||||
|
# SpacesInAngles: Never
|
||||||
|
# SpacesInConditionalStatement: false
|
||||||
|
# SpacesInContainerLiterals: true
|
||||||
|
# SpacesInCStyleCastParentheses: false
|
||||||
|
## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
|
||||||
|
## our comment capitalization at the same time.
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 0
|
||||||
|
Maximum: -1
|
||||||
|
# SpacesInParentheses: false
|
||||||
|
# SpacesInSquareBrackets: false
|
||||||
|
# SpaceBeforeSquareBrackets: false
|
||||||
|
# BitFieldColonSpacing: Both
|
||||||
|
# StatementAttributeLikeMacros:
|
||||||
|
# - Q_EMIT
|
||||||
|
# StatementMacros:
|
||||||
|
# - Q_UNUSED
|
||||||
|
# - QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 4
|
||||||
|
# UseCRLF: false
|
||||||
|
UseTab: Always
|
||||||
|
# WhitespaceSensitiveMacros:
|
||||||
|
# - STRINGIZE
|
||||||
|
# - PP_STRINGIZE
|
||||||
|
# - BOOST_PP_STRINGIZE
|
||||||
|
# - NS_SWIFT_NAME
|
||||||
|
# - CF_SWIFT_NAME
|
||||||
|
---
|
||||||
|
### C++ specific config ###
|
||||||
|
Language: Cpp
|
||||||
|
Standard: c++17
|
||||||
|
---
|
||||||
|
### ObjC specific config ###
|
||||||
|
Language: ObjC
|
||||||
|
# ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
# ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
# ObjCSpaceAfterProperty: false
|
||||||
|
# ObjCSpaceBeforeProtocolList: true
|
||||||
|
---
|
||||||
|
### Java specific config ###
|
||||||
|
Language: Java
|
||||||
|
# BreakAfterJavaFieldAnnotations: false
|
||||||
|
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
|
||||||
|
...
|
|
@ -47,3 +47,12 @@ I suggest you visit the [wiki](https://github.com/Quill-OS/quill/wiki). Feel fre
|
||||||
If you like this project and want to improve it in some way, feel free to fork this repository or [one of the subprojects this organization hosts](https://github.com/Quill-OS), then make a [pull request](https://github.com/Quill-OS/quill/pulls). I'll be happy to review it when I have time. You can also join the official [Matrix space](https://matrix.to/#/#inkbox-os-project:matrix.org), [Discord server](https://discord.com/invite/uSWtWbY23m) or [Linen](https://www.linen.dev/s/quill-os) if you'd like to chat a bit.
|
If you like this project and want to improve it in some way, feel free to fork this repository or [one of the subprojects this organization hosts](https://github.com/Quill-OS), then make a [pull request](https://github.com/Quill-OS/quill/pulls). I'll be happy to review it when I have time. You can also join the official [Matrix space](https://matrix.to/#/#inkbox-os-project:matrix.org), [Discord server](https://discord.com/invite/uSWtWbY23m) or [Linen](https://www.linen.dev/s/quill-os) if you'd like to chat a bit.
|
||||||
<br><br>
|
<br><br>
|
||||||
On the other hand, if you don't have the appropriate coding skills or just want to help in some way, feel free to make a donation at my [PayPal account](https://paypal.me/inkboxos/), [LiberaPay](https://liberapay.com/tux-linux/), or via Bitcoin: 3MmXq5o78b4C7ub5sb7F5WVC86jzc6PzSN . I'm a student and motivation has been the only thing that has helped me maintain this project for the last few years. Developing an entire operating system on my own was not an easy task. I have time, but I like to spend it wisely.
|
On the other hand, if you don't have the appropriate coding skills or just want to help in some way, feel free to make a donation at my [PayPal account](https://paypal.me/inkboxos/), [LiberaPay](https://liberapay.com/tux-linux/), or via Bitcoin: 3MmXq5o78b4C7ub5sb7F5WVC86jzc6PzSN . I'm a student and motivation has been the only thing that has helped me maintain this project for the last few years. Developing an entire operating system on my own was not an easy task. I have time, but I like to spend it wisely.
|
||||||
|
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
Make sure you have the following requirements installed on your system:
|
||||||
|
* a c/cpp profiler
|
||||||
|
* `libsndfile-dev`
|
||||||
|
|
||||||
|
Next open the `inkbox.pro` file qith QTCreator
|
286
inkbox.pro
286
inkbox.pro
|
@ -24,148 +24,172 @@ DEFINES += GIT_COMMIT=\\\"$$GIT_COMMIT\\\"
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
src/apps/todo.cpp \
|
src/platform/device.cpp \
|
||||||
|
src/platform/device_desktop.cpp \
|
||||||
|
src/platform/device_kindle_touch.cpp \
|
||||||
|
src/platform/device_kobo_aura_edition2.cpp \
|
||||||
|
src/platform/device_kobo_clarahd.cpp \
|
||||||
|
src/platform/device_kobo_glo.cpp \
|
||||||
|
src/platform/device_kobo_glohd.cpp \
|
||||||
|
src/platform/device_kobo_libra.cpp \
|
||||||
|
src/platform/device_kobo_mini.cpp \
|
||||||
|
src/platform/device_kobo_nia.cpp \
|
||||||
|
src/platform/device_kobo_touch.cpp \
|
||||||
|
src/ui/apps/todo.cpp \
|
||||||
src/audio/audiothread.cpp \
|
src/audio/audiothread.cpp \
|
||||||
src/splash/alert.cpp \
|
src/ui/apps/apps.cpp \
|
||||||
src/apps/apps.cpp \
|
|
||||||
src/telemetry/telemetry.cpp \
|
src/telemetry/telemetry.cpp \
|
||||||
src/widgets/dialogs/audio/audiodialog.cpp \
|
src/ui/splash/splashAlert.cpp \
|
||||||
src/widgets/dialogs/audio/audiofile.cpp \
|
src/ui/ui.cpp \
|
||||||
src/widgets/dialogs/audio/audiofilequeue.cpp \
|
src/ui/widgets/dialogs/audio/audiodialog.cpp \
|
||||||
src/widgets/dialogs/library/bookinfodialog.cpp \
|
src/ui/widgets/dialogs/audio/audiofile.cpp \
|
||||||
src/widgets/dialogs/library/bookoptionsdialog.cpp \
|
src/ui/widgets/dialogs/audio/audiofilequeue.cpp \
|
||||||
src/widgets/dialogs/brightnessdialog.cpp \
|
src/ui/widgets/dialogs/library/bookinfodialog.cpp \
|
||||||
src/apps/calendarapp.cpp \
|
src/ui/widgets/dialogs/library/bookoptionsdialog.cpp \
|
||||||
src/widgets/dialogs/reader/highlightslistdialog.cpp \
|
src/ui/widgets/dialogs/brightnessdialog.cpp \
|
||||||
src/widgets/dialogs/reader/textdialog.cpp \
|
src/ui/apps/calendarapp.cpp \
|
||||||
src/widgets/dialogs/wifi/connectiondialog.cpp \
|
src/ui/widgets/dialogs/reader/highlightslistdialog.cpp \
|
||||||
src/widgets/dialogs/wifi/network.cpp \
|
src/ui/widgets/dialogs/reader/textdialog.cpp \
|
||||||
src/widgets/dialogs/wifi/wifilogger.cpp \
|
src/ui/widgets/dialogs/wifi/connectiondialog.cpp \
|
||||||
src/widgets/misc/egg.cpp \
|
src/ui/widgets/dialogs/wifi/network.cpp \
|
||||||
src/widgets/reader/dictionarywidget.cpp \
|
src/ui/widgets/dialogs/wifi/wifilogger.cpp \
|
||||||
src/encfs/encryptionmanager.cpp \
|
src/ui/widgets/misc/egg.cpp \
|
||||||
src/widgets/dialogs/generaldialog.cpp \
|
src/ui/widgets/reader/dictionarywidget.cpp \
|
||||||
src/homeWidget/homepagewidget.cpp \
|
src/ui/crypto/encryptionmanager.cpp \
|
||||||
src/widgets/misc/hourglassanimationwidget.cpp \
|
src/ui/widgets/dialogs/generaldialog.cpp \
|
||||||
src/widgets/dialogs/kobox/koboxappsdialog.cpp \
|
src/ui/home/homepagewidget.cpp \
|
||||||
src/settings/koboxsettings.cpp \
|
src/ui/widgets/misc/hourglassanimationwidget.cpp \
|
||||||
src/onlineLibrary/librarywidget.cpp \
|
src/ui/widgets/dialogs/kobox/koboxappsdialog.cpp \
|
||||||
src/localLibrary/locallibrarywidget.cpp \
|
src/ui/settings/koboxsettings.cpp \
|
||||||
|
src/ui/onlineLibrary/librarywidget.cpp \
|
||||||
|
src/ui/localLibrary/locallibrarywidget.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/homeWidget/mainwindow.cpp \
|
src/ui/home/mainwindow.cpp \
|
||||||
src/otaUpdate/otamanager.cpp \
|
src/ui/otaUpdate/otamanager.cpp \
|
||||||
src/widgets/interfaceWidgets/qclickablelabel.cpp \
|
src/ui/widgets/interfaceWidgets/qclickablelabel.cpp \
|
||||||
src/widgets/interfaceWidgets/qtooltiplabel.cpp \
|
src/ui/widgets/interfaceWidgets/qtooltiplabel.cpp \
|
||||||
src/quit/quit.cpp \
|
src/ui/quit/quit.cpp \
|
||||||
src/reader/reader.cpp \
|
src/ui/reader/reader.cpp \
|
||||||
src/apps/savedwords.cpp \
|
src/ui/apps/savedwords.cpp \
|
||||||
src/widgets/text/searchresultswidget.cpp \
|
src/ui/widgets/text/searchresultswidget.cpp \
|
||||||
src/settings/settings.cpp \
|
src/ui/settings/settings.cpp \
|
||||||
src/settings/settingschooser.cpp \
|
src/ui/settings/settingschooser.cpp \
|
||||||
src/widgets/text/textwidget.cpp \
|
src/ui/widgets/text/textwidget.cpp \
|
||||||
src/widgets/interfaceWidgets/toast.cpp \
|
src/ui/widgets/interfaceWidgets/toast.cpp \
|
||||||
src/splash/usbmsSplash.cpp \
|
src/ui/splash/usbmsSplash.cpp \
|
||||||
src/apps/userapps.cpp \
|
src/ui/apps/userapps.cpp \
|
||||||
src/widgets/virtualKeyboard/virtualkeyboard.cpp \
|
src/ui/widgets/virtualKeyboard/virtualkeyboard.cpp \
|
||||||
src/widgets/virtualKeyboard/virtualkeypad.cpp \
|
src/ui/widgets/virtualKeyboard/virtualkeypad.cpp \
|
||||||
src/widgets/dialogs/wifi/wifidialog.cpp \
|
src/ui/widgets/dialogs/wifi/wifidialog.cpp \
|
||||||
src/widgets/dialogs/powerDaemon/sleepdialog.cpp \
|
src/ui/widgets/dialogs/powerDaemon/sleepdialog.cpp \
|
||||||
src/powerDaemon/sleepthread.cpp \
|
src/powerDaemon/sleepthread.cpp \
|
||||||
src/settings/powerdaemonsettings.cpp
|
src/ui/settings/powerdaemonsettings.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/audio/audiothread.h \
|
src/audio/audiothread.h \
|
||||||
src/apps/todo.h \
|
src/platform/device.h \
|
||||||
src/splash/alert.h \
|
src/platform/device_desktop.h \
|
||||||
src/apps/apps.h \
|
src/platform/device_kindle_touch.h \
|
||||||
|
src/platform/device_kobo_aura_edition2.h \
|
||||||
|
src/platform/device_kobo_clarahd.h \
|
||||||
|
src/platform/device_kobo_glo.h \
|
||||||
|
src/platform/device_kobo_glohd.h \
|
||||||
|
src/platform/device_kobo_libra.h \
|
||||||
|
src/platform/device_kobo_mini.h \
|
||||||
|
src/platform/device_kobo_nia.h \
|
||||||
|
src/platform/device_kobo_touch.h \
|
||||||
|
src/ui/apps/todo.h \
|
||||||
|
src/ui/apps/apps.h \
|
||||||
src/telemetry/telemetry.h \
|
src/telemetry/telemetry.h \
|
||||||
src/widgets/dialogs/audio/audiodialog.h \
|
src/ui/splash/splashAlert.h \
|
||||||
src/widgets/dialogs/audio/audiofile.h \
|
src/ui/ui.h \
|
||||||
src/widgets/dialogs/audio/audiofilequeue.h \
|
src/ui/widgets/dialogs/audio/audiodialog.h \
|
||||||
src/widgets/dialogs/library/bookinfodialog.h \
|
src/ui/widgets/dialogs/audio/audiofile.h \
|
||||||
src/widgets/dialogs/library/bookoptionsdialog.h \
|
src/ui/widgets/dialogs/audio/audiofilequeue.h \
|
||||||
src/widgets/dialogs/brightnessdialog.h \
|
src/ui/widgets/dialogs/library/bookinfodialog.h \
|
||||||
src/apps/calendarapp.h \
|
src/ui/widgets/dialogs/library/bookoptionsdialog.h \
|
||||||
src/widgets/dialogs/reader/highlightslistdialog.h \
|
src/ui/widgets/dialogs/brightnessdialog.h \
|
||||||
src/widgets/dialogs/reader/textdialog.h \
|
src/ui/apps/calendarapp.h \
|
||||||
src/widgets/dialogs/wifi/connectiondialog.h \
|
src/ui/widgets/dialogs/reader/highlightslistdialog.h \
|
||||||
src/widgets/dialogs/wifi/network.h \
|
src/ui/widgets/dialogs/reader/textdialog.h \
|
||||||
src/widgets/dialogs/wifi/wifilogger.h \
|
src/ui/widgets/dialogs/wifi/connectiondialog.h \
|
||||||
src/widgets/misc/egg.h \
|
src/ui/widgets/dialogs/wifi/network.h \
|
||||||
src/widgets/reader/dictionarywidget.h \
|
src/ui/widgets/dialogs/wifi/wifilogger.h \
|
||||||
src/encfs/encryptionmanager.h \
|
src/ui/widgets/misc/egg.h \
|
||||||
|
src/ui/widgets/reader/dictionarywidget.h \
|
||||||
|
src/ui/crypto/encryptionmanager.h \
|
||||||
src/functions.h \
|
src/functions.h \
|
||||||
src/widgets/dialogs/generaldialog.h \
|
src/ui/widgets/dialogs/generaldialog.h \
|
||||||
src/homeWidget/homepagewidget.h \
|
src/ui/home/homepagewidget.h \
|
||||||
src/widgets/misc/hourglassanimationwidget.h \
|
src/ui/widgets/misc/hourglassanimationwidget.h \
|
||||||
src/widgets/dialogs/kobox/koboxappsdialog.h \
|
src/ui/widgets/dialogs/kobox/koboxappsdialog.h \
|
||||||
src/settings/koboxsettings.h \
|
src/ui/settings/koboxsettings.h \
|
||||||
src/onlineLibrary/librarywidget.h \
|
src/ui/onlineLibrary/librarywidget.h \
|
||||||
src/localLibrary/locallibrarywidget.h \
|
src/ui/localLibrary/locallibrarywidget.h \
|
||||||
src/homeWidget/mainwindow.h \
|
src/ui/home/mainwindow.h \
|
||||||
src/otaUpdate/otamanager.h \
|
src/ui/otaUpdate/otamanager.h \
|
||||||
src/widgets/interfaceWidgets/qclickablelabel.h \
|
src/ui/widgets/interfaceWidgets/qclickablelabel.h \
|
||||||
src/widgets/interfaceWidgets/qtooltiplabel.h \
|
src/ui/widgets/interfaceWidgets/qtooltiplabel.h \
|
||||||
src/quit/quit.h \
|
src/ui/quit/quit.h \
|
||||||
src/reader/reader.h \
|
src/ui/reader/reader.h \
|
||||||
src/apps/savedwords.h \
|
src/ui/apps/savedwords.h \
|
||||||
src/widgets/text/searchresultswidget.h \
|
src/ui/widgets/text/searchresultswidget.h \
|
||||||
src/settings/settings.h \
|
src/ui/settings/settings.h \
|
||||||
src/settings/settingschooser.h \
|
src/ui/settings/settingschooser.h \
|
||||||
src/widgets/text/textwidget.h \
|
src/ui/widgets/text/textwidget.h \
|
||||||
src/widgets/interfaceWidgets/toast.h \
|
src/ui/widgets/interfaceWidgets/toast.h \
|
||||||
src/splash/usbmsSplash.h \
|
src/ui/splash/usbmsSplash.h \
|
||||||
src/apps/userapps.h \
|
src/ui/apps/userapps.h \
|
||||||
src/widgets/virtualKeyboard/virtualkeyboard.h \
|
src/ui/widgets/virtualKeyboard/virtualkeyboard.h \
|
||||||
src/widgets/virtualKeyboard/virtualkeypad.h \
|
src/ui/widgets/virtualKeyboard/virtualkeypad.h \
|
||||||
src/widgets/dialogs/wifi/wifidialog.h \
|
src/ui/widgets/dialogs/wifi/wifidialog.h \
|
||||||
src/widgets/dialogs/powerDaemon/sleepdialog.h \
|
src/ui/widgets/dialogs/powerDaemon/sleepdialog.h \
|
||||||
src/powerDaemon/sleepthread.h \
|
src/powerDaemon/sleepthread.h \
|
||||||
src/settings/powerdaemonsettings.h
|
src/ui/settings/powerdaemonsettings.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
src/apps/todo.ui \
|
src/ui/apps/todo.ui \
|
||||||
src/splash/alert.ui \
|
src/ui/apps/apps.ui \
|
||||||
src/apps/apps.ui \
|
src/ui/splash/splashAlert.ui \
|
||||||
src/widgets/dialogs/audio/audiodialog.ui \
|
src/ui/widgets/dialogs/audio/audiodialog.ui \
|
||||||
src/widgets/dialogs/audio/audiofile.ui \
|
src/ui/widgets/dialogs/audio/audiofile.ui \
|
||||||
src/widgets/dialogs/audio/audiofilequeue.ui \
|
src/ui/widgets/dialogs/audio/audiofilequeue.ui \
|
||||||
src/widgets/dialogs/library/bookinfodialog.ui \
|
src/ui/widgets/dialogs/library/bookinfodialog.ui \
|
||||||
src/widgets/dialogs/library/bookoptionsdialog.ui \
|
src/ui/widgets/dialogs/library/bookoptionsdialog.ui \
|
||||||
src/widgets/dialogs/brightnessdialog.ui \
|
src/ui/widgets/dialogs/brightnessdialog.ui \
|
||||||
src/apps/calendarapp.ui \
|
src/ui/apps/calendarapp.ui \
|
||||||
src/widgets/dialogs/reader/highlightslistdialog.ui \
|
src/ui/widgets/dialogs/reader/highlightslistdialog.ui \
|
||||||
src/widgets/dialogs/reader/textdialog.ui \
|
src/ui/widgets/dialogs/reader/textdialog.ui \
|
||||||
src/widgets/dialogs/wifi/connectiondialog.ui \
|
src/ui/widgets/dialogs/wifi/connectiondialog.ui \
|
||||||
src/widgets/dialogs/wifi/network.ui \
|
src/ui/widgets/dialogs/wifi/network.ui \
|
||||||
src/widgets/dialogs/wifi/wifilogger.ui \
|
src/ui/widgets/dialogs/wifi/wifilogger.ui \
|
||||||
src/widgets/misc/egg.ui \
|
src/ui/widgets/misc/egg.ui \
|
||||||
src/widgets/reader/dictionarywidget.ui \
|
src/ui/widgets/reader/dictionarywidget.ui \
|
||||||
src/encfs/encryptionmanager.ui \
|
src/ui/crypto/encryptionmanager.ui \
|
||||||
src/widgets/dialogs/generaldialog.ui \
|
src/ui/widgets/dialogs/generaldialog.ui \
|
||||||
src/homeWidget/homepagewidget.ui \
|
src/ui/home/homepagewidget.ui \
|
||||||
src/widgets/misc/hourglassanimationwidget.ui \
|
src/ui/widgets/misc/hourglassanimationwidget.ui \
|
||||||
src/widgets/dialogs/kobox/koboxappsdialog.ui \
|
src/ui/widgets/dialogs/kobox/koboxappsdialog.ui \
|
||||||
src/settings/koboxsettings.ui \
|
src/ui/settings/koboxsettings.ui \
|
||||||
src/onlineLibrary/librarywidget.ui \
|
src/ui/onlineLibrary/librarywidget.ui \
|
||||||
src/localLibrary/locallibrarywidget.ui \
|
src/ui/localLibrary/locallibrarywidget.ui \
|
||||||
src/homeWidget/mainwindow.ui \
|
src/ui/home/mainwindow.ui \
|
||||||
src/otaUpdate/otamanager.ui \
|
src/ui/otaUpdate/otamanager.ui \
|
||||||
src/quit/quit.ui \
|
src/ui/quit/quit.ui \
|
||||||
src/reader/reader.ui \
|
src/ui/reader/reader.ui \
|
||||||
src/apps/savedwords.ui \
|
src/ui/apps/savedwords.ui \
|
||||||
src/widgets/text/searchresultswidget.ui \
|
src/ui/widgets/text/searchresultswidget.ui \
|
||||||
src/settings/settings.ui \
|
src/ui/settings/settings.ui \
|
||||||
src/settings/settingschooser.ui \
|
src/ui/settings/settingschooser.ui \
|
||||||
src/widgets/text/textwidget.ui \
|
src/ui/widgets/text/textwidget.ui \
|
||||||
src/widgets/interfaceWidgets/toast.ui \
|
src/ui/widgets/interfaceWidgets/toast.ui \
|
||||||
src/splash/usbmsSplash.ui \
|
src/ui/splash/usbmsSplash.ui \
|
||||||
src/apps/userapps.ui \
|
src/ui/apps/userapps.ui \
|
||||||
src/widgets/virtualKeyboard/virtualkeyboard.ui \
|
src/ui/widgets/virtualKeyboard/virtualkeyboard.ui \
|
||||||
src/widgets/virtualKeyboard/virtualkeypad.ui \
|
src/ui/widgets/virtualKeyboard/virtualkeypad.ui \
|
||||||
src/widgets/dialogs/wifi/wifidialog.ui \
|
src/ui/widgets/dialogs/wifi/wifidialog.ui \
|
||||||
src/widgets/dialogs/powerDaemon/sleepdialog.ui \
|
src/ui/widgets/dialogs/powerDaemon/sleepdialog.ui \
|
||||||
src/settings/powerdaemonsettings.ui
|
src/ui/settings/powerdaemonsettings.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
@ -173,7 +197,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
src/eink.qrc
|
src/ui/eink.qrc
|
||||||
|
|
||||||
INCLUDEPATH += $$system(find ./ -type d -print -path ./.git -prune | grep -v "./.git")
|
INCLUDEPATH += $$system(find ./ -type d -print -path ./.git -prune | grep -v "./.git")
|
||||||
INCLUDEPATH += $$PWD/libs/libsndfile/include/
|
INCLUDEPATH += $$PWD/libs/libsndfile/include/
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
#include "calendarapp.h"
|
|
||||||
#include "ui_calendarapp.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
calendarApp::calendarApp(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::calendarApp)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
calendarApp::setFont(QFont("u001"));
|
|
||||||
ui->backBtn->setFont(QFont("Inter"));
|
|
||||||
ui->backBtn->setStyleSheet("font-weight: bold");
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
ui->backBtn->setProperty("type", "borderless");
|
|
||||||
}
|
|
||||||
|
|
||||||
calendarApp::~calendarApp()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void calendarApp::on_backBtn_clicked()
|
|
||||||
{
|
|
||||||
calendarApp::close();
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
#include "savedwords.h"
|
|
||||||
#include "ui_savedwords.h"
|
|
||||||
#include "functions.h"
|
|
||||||
#include <QStringListModel>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
savedwords::savedwords(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::savedwords)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
savedwords::setFont(QFont("u001"));
|
|
||||||
ui->savedWordsLabel->setFont(QFont("Inter"));
|
|
||||||
ui->backBtn->setFont(QFont("Inter"));
|
|
||||||
ui->clearBtn->setFont(QFont("Inter"));
|
|
||||||
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
ui->backBtn->setProperty("type", "borderless");
|
|
||||||
ui->clearBtn->setProperty("type", "borderless");
|
|
||||||
|
|
||||||
ui->savedWordsLabel->setStyleSheet("font-weight: bold");
|
|
||||||
ui->wordsList->setStyleSheet("font-size: 10pt");
|
|
||||||
ui->backBtn->setStyleSheet("font-weight: bold");
|
|
||||||
ui->clearBtn->setStyleSheet("font-weight: bold");
|
|
||||||
|
|
||||||
checkwords();
|
|
||||||
|
|
||||||
QStringListModel * model = new QStringListModel(this);
|
|
||||||
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
|
||||||
model->setStringList(list);
|
|
||||||
ui->wordsList->setModel(model);
|
|
||||||
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
||||||
}
|
|
||||||
|
|
||||||
savedwords::~savedwords()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void savedwords::on_backBtn_clicked()
|
|
||||||
{
|
|
||||||
// Workaround for the random strange memory corruption error
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void savedwords::on_clearBtn_clicked()
|
|
||||||
{
|
|
||||||
// Warning: possible memory leak here. Though, usually, when you press the "Clear" button and all clears up, you don't have to press it again ;)
|
|
||||||
log("Wiping Saved Words list", className);
|
|
||||||
save_word_init();
|
|
||||||
checkwords();
|
|
||||||
QStringListModel* model = new QStringListModel(this);
|
|
||||||
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
|
||||||
model->setStringList(list);
|
|
||||||
ui->wordsList->setModel(model);
|
|
||||||
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
||||||
}
|
|
||||||
|
|
||||||
void savedwords::checkwords() {
|
|
||||||
QFile words_list(".config/06-words/config");
|
|
||||||
words_list.open(QIODevice::ReadWrite);
|
|
||||||
QTextStream in (&words_list);
|
|
||||||
words = in.readAll();
|
|
||||||
words_list.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void savedwords::save_word_init() {
|
|
||||||
QFile words(".config/06-words/config");
|
|
||||||
words.open(QIODevice::ReadWrite);
|
|
||||||
QTextStream in (&words);
|
|
||||||
QString words_list = in.readAll();
|
|
||||||
string words_list_str = words_list.toStdString();
|
|
||||||
words.close();
|
|
||||||
|
|
||||||
ofstream fhandler;
|
|
||||||
fhandler.open(".config/06-words/config");
|
|
||||||
fhandler << "";
|
|
||||||
fhandler.close();
|
|
||||||
}
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
audiothread::audiothread() {}
|
AudioThread::AudioThread() {}
|
||||||
|
|
||||||
void audiothread::start() {
|
void AudioThread::start() {
|
||||||
log("Audio thread monitor available", className);
|
log("Audio thread monitor available", className);
|
||||||
|
|
||||||
// QTimer doesn't work in such loops
|
// QTimer doesn't work in such loops
|
||||||
|
@ -86,7 +86,7 @@ void audiothread::start() {
|
||||||
// I have no explanation as to why this needs to connect/disconnect every time.
|
// I have no explanation as to why this needs to connect/disconnect every time.
|
||||||
// while (recv(client_sockfd, buffer_tmp, 1, 0) > 0) {
|
// while (recv(client_sockfd, buffer_tmp, 1, 0) > 0) {
|
||||||
// ^ This line makes InkBox freeze
|
// ^ This line makes InkBox freeze
|
||||||
void audiothread::sendInfo(QString message) {
|
void AudioThread::sendInfo(QString message) {
|
||||||
log("Sending message: *" + message + "*", className);
|
log("Sending message: *" + message + "*", className);
|
||||||
// Send
|
// Send
|
||||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
@ -113,7 +113,7 @@ void audiothread::sendInfo(QString message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutex managed outside of the function
|
// Mutex managed outside of the function
|
||||||
void audiothread::audioProgress() {
|
void AudioThread::audioProgress() {
|
||||||
global::audio::progressSeconds = global::audio::progressSeconds + 1;
|
global::audio::progressSeconds = global::audio::progressSeconds + 1;
|
||||||
// log("Progress, +1 sec: " + QString::number(global::audio::progressSeconds), className);
|
// log("Progress, +1 sec: " + QString::number(global::audio::progressSeconds), className);
|
||||||
if(global::audio::progressSeconds >= global::audio::queue[global::audio::itemCurrentlyPlaying].lengths) {
|
if(global::audio::progressSeconds >= global::audio::queue[global::audio::itemCurrentlyPlaying].lengths) {
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class audiothread : public QObject
|
class AudioThread : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
audiothread();
|
AudioThread();
|
||||||
void sendInfo(QString message);
|
void sendInfo(QString message);
|
||||||
int sockfd;
|
int sockfd;
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
|
124
src/eink.qrc
124
src/eink.qrc
|
@ -1,124 +0,0 @@
|
||||||
<RCC>
|
|
||||||
<qresource prefix="/">
|
|
||||||
<file>resources/checkbox-checked.png</file>
|
|
||||||
<file>resources/checkbox-unchecked.png</file>
|
|
||||||
<file>resources/align-center.png</file>
|
|
||||||
<file>resources/align-justify.png</file>
|
|
||||||
<file>resources/align-left.png</file>
|
|
||||||
<file>resources/align-right.png</file>
|
|
||||||
<file>resources/chesterton.jpg</file>
|
|
||||||
<file>resources/alcott.jpg</file>
|
|
||||||
<file>resources/davies.jpg</file>
|
|
||||||
<file>resources/king.jpg</file>
|
|
||||||
<file>resources/star.png</file>
|
|
||||||
<file>resources/starred_star.png</file>
|
|
||||||
<file>resources/close.png</file>
|
|
||||||
<file>resources/chevron-left.png</file>
|
|
||||||
<file>resources/chevron-right.png</file>
|
|
||||||
<file>resources/chevron-down.png</file>
|
|
||||||
<file>resources/chevron-up.png</file>
|
|
||||||
<file>resources/christie.png</file>
|
|
||||||
<file>resources/exit.png</file>
|
|
||||||
<file>resources/usbms.png</file>
|
|
||||||
<file>resources/settings.png</file>
|
|
||||||
<file>resources/search.png</file>
|
|
||||||
<file>resources/power.png</file>
|
|
||||||
<file>resources/book.png</file>
|
|
||||||
<file>resources/apps.png</file>
|
|
||||||
<file>resources/battery_half.png</file>
|
|
||||||
<file>resources/battery_full.png</file>
|
|
||||||
<file>resources/battery_empty.png</file>
|
|
||||||
<file>resources/battery_charging.png</file>
|
|
||||||
<file>resources/alert.png</file>
|
|
||||||
<file>resources/eink-dark.qss</file>
|
|
||||||
<file>resources/frontlight.png</file>
|
|
||||||
<file>resources/fonts/CrimsonPro-Bold.ttf</file>
|
|
||||||
<file>resources/fonts/CrimsonPro-Italic.ttf</file>
|
|
||||||
<file>resources/fonts/CrimsonPro-Regular.ttf</file>
|
|
||||||
<file>resources/check.png</file>
|
|
||||||
<file>resources/minus.png</file>
|
|
||||||
<file>resources/plus.png</file>
|
|
||||||
<file>resources/battery_alert.png</file>
|
|
||||||
<file>resources/apps-inverted.png</file>
|
|
||||||
<file>resources/home.png</file>
|
|
||||||
<file>resources/settings-inverted.png</file>
|
|
||||||
<file>resources/kobox-icon.png</file>
|
|
||||||
<file>resources/X11.png</file>
|
|
||||||
<file>resources/info.png</file>
|
|
||||||
<file>resources/nightmode-empty.png</file>
|
|
||||||
<file>resources/nightmode-full.png</file>
|
|
||||||
<file>resources/backspace.png</file>
|
|
||||||
<file>resources/x-circle.png</file>
|
|
||||||
<file>resources/fonts/Bitter-MediumItalic.ttf</file>
|
|
||||||
<file>resources/fonts/Bitter-Medium.ttf</file>
|
|
||||||
<file>resources/fonts/Bitter-Bold.ttf</file>
|
|
||||||
<file>resources/fonts/Bitter-BoldItalic.ttf</file>
|
|
||||||
<file>resources/fonts/CrimsonPro-BoldItalic.ttf</file>
|
|
||||||
<file>resources/fonts/IbarraRealNova-MediumItalic.ttf</file>
|
|
||||||
<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>
|
|
||||||
<file>resources/zoom-in.png</file>
|
|
||||||
<file>resources/zoom-out.png</file>
|
|
||||||
<file>resources/encryption.png</file>
|
|
||||||
<file>resources/check-display.png</file>
|
|
||||||
<file>resources/hourglass-bottom.png</file>
|
|
||||||
<file>resources/hourglass-top.png</file>
|
|
||||||
<file>resources/error.png</file>
|
|
||||||
<file>resources/alert-triangle.png</file>
|
|
||||||
<file>resources/online-library.png</file>
|
|
||||||
<file>resources/online-library-inverted.png</file>
|
|
||||||
<file>resources/cover_unavailable.png</file>
|
|
||||||
<file>resources/clock-inverted.png</file>
|
|
||||||
<file>resources/clock.png</file>
|
|
||||||
<file>resources/eink-square-encfs.qss</file>
|
|
||||||
<file>resources/tzlist</file>
|
|
||||||
<file>resources/edit.png</file>
|
|
||||||
<file>resources/save.png</file>
|
|
||||||
<file>resources/book_inverted.png</file>
|
|
||||||
<file>resources/arrow-left.png</file>
|
|
||||||
<file>resources/arrow-right.png</file>
|
|
||||||
<file>resources/file-text.png</file>
|
|
||||||
<file>resources/pin.png</file>
|
|
||||||
<file>resources/highlight.png</file>
|
|
||||||
<file>resources/unhighlight.png</file>
|
|
||||||
<file>resources/view-highlights.png</file>
|
|
||||||
<file>resources/stop.png</file>
|
|
||||||
<file>resources/refresh.png</file>
|
|
||||||
<file>resources/hide.png</file>
|
|
||||||
<file>resources/show.png</file>
|
|
||||||
<file>resources/christie.jpg</file>
|
|
||||||
<file>resources/encryption-small.png</file>
|
|
||||||
<file>resources/lock.png</file>
|
|
||||||
<file>resources/public.png</file>
|
|
||||||
<file>resources/wifi-0.png</file>
|
|
||||||
<file>resources/wifi-25.png</file>
|
|
||||||
<file>resources/wifi-50.png</file>
|
|
||||||
<file>resources/wifi-75.png</file>
|
|
||||||
<file>resources/wifi-100.png</file>
|
|
||||||
<file>resources/log.png</file>
|
|
||||||
<file>resources/new.png</file>
|
|
||||||
<file>resources/checkbox-unchecked-small.png</file>
|
|
||||||
<file>resources/checkbox-checked-small.png</file>
|
|
||||||
<file>resources/checkbox-x-small.png</file>
|
|
||||||
<file>resources/checkbox-x.png</file>
|
|
||||||
<file>resources/folder.png</file>
|
|
||||||
<file>resources/question-mark.png</file>
|
|
||||||
<file>resources/refresh-small.png</file>
|
|
||||||
<file>resources/checkbox-indeterminate.png</file>
|
|
||||||
<file>resources/egg/0.jpg</file>
|
|
||||||
<file>resources/egg/1.jpg</file>
|
|
||||||
<file>resources/music-note.png</file>
|
|
||||||
<file>resources/music-library.png</file>
|
|
||||||
<file>resources/next.png</file>
|
|
||||||
<file>resources/music-queue.png</file>
|
|
||||||
<file>resources/play.png</file>
|
|
||||||
<file>resources/previous.png</file>
|
|
||||||
<file>resources/pause.png</file>
|
|
||||||
<file>resources/clean.png</file>
|
|
||||||
<file>resources/usbms-inverted.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
|
@ -1,384 +0,0 @@
|
||||||
#include "encryptionmanager.h"
|
|
||||||
#include "ui_encryptionmanager.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include "usbmsSplash.h"
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
encryptionManager::encryptionManager(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::encryptionManager)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->descriptionLabel->setFont(QFont("u001"));
|
|
||||||
ui->successDescriptionLabel->setFont(QFont("u001"));
|
|
||||||
ui->failureDescriptionLabel->setFont(QFont("u001"));
|
|
||||||
ui->warningDescriptionLabel->setFont(QFont("u001"));
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
ui->encryptionSetupLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
|
||||||
ui->descriptionLabel->setStyleSheet("font-size: 10pt");
|
|
||||||
ui->successLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
|
||||||
ui->successDescriptionLabel->setStyleSheet("font-size: 10pt");
|
|
||||||
ui->failureLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
|
||||||
ui->failureDescriptionLabel->setStyleSheet("font-size: 10pt");
|
|
||||||
ui->setupContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->setupAbortBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->exitSuccessBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->failureContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->acceptBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->usbmsBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
|
||||||
ui->warningLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
|
||||||
ui->warningDescriptionLabel->setStyleSheet("font-size: 10pt");
|
|
||||||
|
|
||||||
// Getting the screen's size
|
|
||||||
float sW = QGuiApplication::screens()[0]->size().width();
|
|
||||||
float sH = QGuiApplication::screens()[0]->size().height();
|
|
||||||
float stdIconWidth;
|
|
||||||
float stdIconHeight;
|
|
||||||
{
|
|
||||||
stdIconWidth = sW / 1.50;
|
|
||||||
stdIconHeight = sH / 1.50;
|
|
||||||
QPixmap pixmap(":/resources/encryption.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->encryptionImageLabel->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
stdIconWidth = sW / 1.65;
|
|
||||||
stdIconHeight = sH / 1.65;
|
|
||||||
QPixmap pixmap(":/resources/check-display.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->checkImageLabel->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
stdIconWidth = sW / 1.65;
|
|
||||||
stdIconHeight = sH / 1.65;
|
|
||||||
QPixmap pixmap(":/resources/error.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->failureImageLabel->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
stdIconWidth = sW / 1.50;
|
|
||||||
stdIconHeight = sH / 1.50;
|
|
||||||
QPixmap pixmap(":/resources/alert-triangle.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->warningImageLabel->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
hourglassAnimationWidgetWindow = new hourglassAnimationWidget();
|
|
||||||
ui->hourglassWidget->insertWidget(0, hourglassAnimationWidgetWindow);
|
|
||||||
ui->hourglassWidget->setCurrentIndex(0);
|
|
||||||
|
|
||||||
setDefaultWorkDir();
|
|
||||||
if(checkconfig(".config/18-encrypted_storage/initial_setup_done") == true or checkconfig("/external_root/run/encfs_repack") == true) {
|
|
||||||
ui->activityWidget->hide();
|
|
||||||
if(checkconfig("/external_root/run/encfs_repack") == false) {
|
|
||||||
setupPassphraseDialogMode = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setupPassphraseDialogMode = 2;
|
|
||||||
}
|
|
||||||
QTimer::singleShot(500, this, SLOT(setupPassphraseDialog()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QDir dir("/mnt/onboard/onboard/encfs-dropbox");
|
|
||||||
if(dir.isEmpty()) {
|
|
||||||
ui->activityWidget->setCurrentIndex(4);
|
|
||||||
mkEncfsDirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
encryptionManager::~encryptionManager()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::on_setupContinueBtn_clicked()
|
|
||||||
{
|
|
||||||
setupPassphraseDialogMode = 0;
|
|
||||||
setupPassphraseDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::setupPassphraseDialog() {
|
|
||||||
/*
|
|
||||||
* setupPassphraseDialogMode can be:
|
|
||||||
* 0: Initial setup
|
|
||||||
* 1: Normal behavior
|
|
||||||
* 2: Repack
|
|
||||||
*/
|
|
||||||
log("Showing passphrase dialog for mode " + QString::number(setupPassphraseDialogMode), className);
|
|
||||||
ui->activityWidget->hide();
|
|
||||||
this->setStyleSheet("background-color: black");
|
|
||||||
global::keyboard::keyboardDialog = true;
|
|
||||||
global::keyboard::encfsDialog = true;
|
|
||||||
global::keyboard::keyboardText = "";
|
|
||||||
generalDialogWindow = new generalDialog();
|
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
|
||||||
if(setupPassphraseDialogMode == 0) {
|
|
||||||
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupEncryptedStorage()));
|
|
||||||
}
|
|
||||||
else if(setupPassphraseDialogMode == 1) {
|
|
||||||
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(unlockEncryptedStorage()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(repackEncryptedStorage()));
|
|
||||||
}
|
|
||||||
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
|
|
||||||
generalDialogWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void encryptionManager::on_setupAbortBtn_clicked()
|
|
||||||
{
|
|
||||||
log("Aborting setup", className);
|
|
||||||
setDefaultWorkDir();
|
|
||||||
writeFile(".config/18-encrypted_storage/status", "false");
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::quit_restart() {
|
|
||||||
log("Restarting InkBox", className);
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::refreshScreen() {
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::showToast(QString messageToDisplay) {
|
|
||||||
global::toast::message = messageToDisplay;
|
|
||||||
toastWindow = new toast(this);
|
|
||||||
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
connect(toastWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
|
||||||
toastWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::setupEncryptedStorage() {
|
|
||||||
log("Setting up encrypted storage", className);
|
|
||||||
this->setStyleSheet("background-color: white");
|
|
||||||
ui->activityWidget->show();
|
|
||||||
if(global::encfs::cancelSetup == true) {
|
|
||||||
global::encfs::cancelSetup = false;
|
|
||||||
ui->activityWidget->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mkEncfsDirs();
|
|
||||||
QString bootstrapPassphrase = global::encfs::passphrase;
|
|
||||||
global::encfs::passphrase = "";
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_create", "true");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
|
||||||
setDefaultWorkDir();
|
|
||||||
writeFile(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
|
||||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
|
||||||
bool exitStatus;
|
|
||||||
ui->activityWidget->setCurrentIndex(3);
|
|
||||||
QTimer * t = new QTimer(this);
|
|
||||||
t->setInterval(1000);
|
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
|
||||||
if(QFile::exists("/external_root/run/encrypted_storage_bootstrap_setup")) {
|
|
||||||
exitStatus = checkconfig("/external_root/run/encrypted_storage_bootstrap_setup");
|
|
||||||
QFile::remove("/external_root/run/encrypted_storage_bootstrap_setup");
|
|
||||||
setupExitWidget(exitStatus);
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
t->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::unlockEncryptedStorage() {
|
|
||||||
log("Trying to unlock encrypted storage", className);
|
|
||||||
if(global::encfs::cancelSetup == true) {
|
|
||||||
global::encfs::cancelSetup = false;
|
|
||||||
poweroff(true);
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->setStyleSheet("background-color: white");
|
|
||||||
ui->activityWidget->show();
|
|
||||||
mkEncfsDirs();
|
|
||||||
QString passphrase = global::encfs::passphrase;
|
|
||||||
global::encfs::passphrase = "";
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted");
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
|
||||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
|
||||||
bool exitStatus;
|
|
||||||
|
|
||||||
QString passphraseTriesStr = readFile("/inkbox/encryptedStoragePassphraseTries");
|
|
||||||
if(passphraseTriesStr.isEmpty()) {
|
|
||||||
passphraseTries = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
passphraseTries = passphraseTriesStr.toInt();
|
|
||||||
passphraseTries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->activityWidget->setCurrentIndex(3);
|
|
||||||
QTimer * t = new QTimer(this);
|
|
||||||
t->setInterval(1000);
|
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
|
||||||
if(QFile::exists("/external_root/run/encfs_mounted")) {
|
|
||||||
exitStatus = true;
|
|
||||||
if(readFile("/external_root/run/encfs_mounted") != "true\n") {
|
|
||||||
exitStatus = false;
|
|
||||||
QFile::remove("/external_root/run/encfs_mounted");
|
|
||||||
QString function = __func__; log(function + ": Invalid passphrase", className);
|
|
||||||
if(setupMessageBoxRan == false) {
|
|
||||||
int delay = 0;
|
|
||||||
if(passphraseTries <= 3) {
|
|
||||||
if(passphraseTries == 0) {
|
|
||||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "0");
|
|
||||||
delay = 5000;
|
|
||||||
}
|
|
||||||
else if(passphraseTries == 1) {
|
|
||||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "1");
|
|
||||||
delay = 10000;
|
|
||||||
}
|
|
||||||
else if(passphraseTries == 2) {
|
|
||||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "2");
|
|
||||||
delay = 20000;
|
|
||||||
}
|
|
||||||
else if(passphraseTries >= 3) {
|
|
||||||
writeFile("/inkbox/encryptedStoragePassphraseTries", "3");
|
|
||||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
|
||||||
currentEpoch += 86400;
|
|
||||||
QString unlockTime_str = QString::number(currentEpoch);
|
|
||||||
global::encfs::unlockTime = QDateTime::fromTime_t(currentEpoch).toString();
|
|
||||||
global::encfs::lockdownMessage = "FATAL: 4 invalid passphrase tries, locking down device until " + global::encfs::unlockTime;
|
|
||||||
writeFile("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str + "\n");
|
|
||||||
global::encfs::lockdown = true;
|
|
||||||
setupMessageBoxRan = true;
|
|
||||||
|
|
||||||
alertWindow = new alert();
|
|
||||||
alertWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
alertWindow->showFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passphraseTries <= 2) {
|
|
||||||
QTimer::singleShot(delay, this, SLOT(setupFailedAuthenticationMessageBox()));
|
|
||||||
setupMessageBoxRan = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log("Unlocking successful", className);
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
t->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::mkEncfsDirs() {
|
|
||||||
log("Creating encrypted storage directories", className);
|
|
||||||
QDir encfsDir;
|
|
||||||
QString encfsPath("/external_root/run/encfs");
|
|
||||||
encfsDir.mkpath(encfsPath);
|
|
||||||
QDir dumpDir;
|
|
||||||
QString dumpPath("/mnt/onboard/onboard/encfs-dropbox");
|
|
||||||
dumpDir.mkpath(dumpPath);
|
|
||||||
QDir decDir;
|
|
||||||
QString decPath("/mnt/onboard/onboard/encfs-decrypted");
|
|
||||||
decDir.mkpath(decPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::on_exitSuccessBtn_clicked()
|
|
||||||
{
|
|
||||||
setDefaultWorkDir();
|
|
||||||
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::setupExitWidget(bool exitStatus) {
|
|
||||||
if(setupExitWidgetRan == false) {
|
|
||||||
if(exitStatus == true) {
|
|
||||||
ui->activityWidget->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeFile(".config/18-encrypted_storage/status", "false");
|
|
||||||
ui->activityWidget->setCurrentIndex(2);
|
|
||||||
}
|
|
||||||
setupExitWidgetRan = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::on_failureContinueBtn_clicked()
|
|
||||||
{
|
|
||||||
setDefaultWorkDir();
|
|
||||||
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::setupFailedAuthenticationMessageBox() {
|
|
||||||
log("Showing 'Authentication failed' message box", className);
|
|
||||||
ui->activityWidget->hide();
|
|
||||||
QMessageBox::critical(this, tr("Invalid argument"), tr("<font face='u001'>Invalid passphrase. Please try again.</font>"));
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::on_acceptBtn_clicked()
|
|
||||||
{
|
|
||||||
writeFile(".config/18-encrypted_storage/status", "false");
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void encryptionManager::on_usbmsBtn_clicked()
|
|
||||||
{
|
|
||||||
log("Showing USBMS splash", className);
|
|
||||||
global::usbms::launchUsbms = true;
|
|
||||||
usbmsWindow = new usbmsSplash();
|
|
||||||
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
|
|
||||||
usbmsWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void encryptionManager::repackEncryptedStorage() {
|
|
||||||
log("Repacking encrypted storage", className);
|
|
||||||
if(global::encfs::cancelSetup == true) {
|
|
||||||
global::encfs::cancelSetup = false;
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->setStyleSheet("background-color: white");
|
|
||||||
ui->activityWidget->show();
|
|
||||||
mkEncfsDirs();
|
|
||||||
QString passphrase = global::encfs::passphrase;
|
|
||||||
global::encfs::passphrase = "";
|
|
||||||
writeFile("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase);
|
|
||||||
QFile::remove("/external_root/run/openrc/started/encfs");
|
|
||||||
writeFile("/opt/ibxd", "encfs_restart\n");
|
|
||||||
bool exitStatus;
|
|
||||||
ui->activityWidget->setCurrentIndex(3);
|
|
||||||
QTimer * t = new QTimer(this);
|
|
||||||
t->setInterval(1000);
|
|
||||||
connect(t, &QTimer::timeout, [&]() {
|
|
||||||
if(QFile::exists("/external_root/run/encfs_repack_status")) {
|
|
||||||
exitStatus = checkconfig("/external_root/run/encfs_repack_status");
|
|
||||||
QFile::remove("/external_root/run/encfs_repack_status");
|
|
||||||
setupExitWidget(exitStatus);
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
t->start();
|
|
||||||
}
|
|
||||||
}
|
|
624
src/functions.h
624
src/functions.h
|
@ -1,40 +1,42 @@
|
||||||
#ifndef FUNCTIONS_H
|
#ifndef FUNCTIONS_H
|
||||||
#define FUNCTIONS_H
|
#define FUNCTIONS_H
|
||||||
|
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QNetworkInterface>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <fstream>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <regex>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <fstream>
|
||||||
#include <QRandomGenerator>
|
#include <regex>
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDirIterator>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonParseError>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonValue>
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
#include <QNetworkInterface>
|
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
// WoW, global variables and namespaces are awesome
|
// WoW, global variables and namespaces are awesome
|
||||||
namespace global {
|
namespace global {
|
||||||
namespace battery {
|
namespace battery {
|
||||||
inline bool showLowBatteryDialog;
|
inline bool showLowBatteryDialog;
|
||||||
inline bool showCriticalBatteryAlert;
|
inline bool showCriticalBatteryAlert;
|
||||||
inline bool batteryAlertLock;
|
inline bool batteryAlertLock;
|
||||||
}
|
} //namespace battery
|
||||||
namespace reader {
|
namespace reader {
|
||||||
inline QString bookFile;
|
inline QString bookFile;
|
||||||
inline int pageNumber;
|
inline int pageNumber;
|
||||||
|
@ -53,13 +55,13 @@ namespace global {
|
||||||
inline int fontSize;
|
inline int fontSize;
|
||||||
inline int margins;
|
inline int margins;
|
||||||
inline QString currentViewportText;
|
inline QString currentViewportText;
|
||||||
}
|
} //namespace reader
|
||||||
namespace kobox {
|
namespace kobox {
|
||||||
inline bool showKoboxSplash;
|
inline bool showKoboxSplash;
|
||||||
inline bool koboxSettingsRebootDialog;
|
inline bool koboxSettingsRebootDialog;
|
||||||
inline bool resetKoboxUserDataBool;
|
inline bool resetKoboxUserDataBool;
|
||||||
inline bool resetKoboxDialog;
|
inline bool resetKoboxDialog;
|
||||||
}
|
} //namespace kobox
|
||||||
namespace mainwindow {
|
namespace mainwindow {
|
||||||
namespace tabSwitcher {
|
namespace tabSwitcher {
|
||||||
inline bool repaint;
|
inline bool repaint;
|
||||||
|
@ -72,16 +74,16 @@ namespace global {
|
||||||
inline bool libraryWidgetSelected;
|
inline bool libraryWidgetSelected;
|
||||||
inline bool localLibraryWidgetCreated;
|
inline bool localLibraryWidgetCreated;
|
||||||
inline bool localLibraryWidgetSelected;
|
inline bool localLibraryWidgetSelected;
|
||||||
}
|
} //namespace tabSwitcher
|
||||||
inline bool updateDialog;
|
inline bool updateDialog;
|
||||||
inline bool lowBatteryDialog;
|
inline bool lowBatteryDialog;
|
||||||
}
|
} //namespace mainwindow
|
||||||
namespace usbms {
|
namespace usbms {
|
||||||
inline bool usbmsDialog;
|
inline bool usbmsDialog;
|
||||||
inline bool showUsbmsDialog;
|
inline bool showUsbmsDialog;
|
||||||
inline bool launchUsbms;
|
inline bool launchUsbms;
|
||||||
inline bool koboxExportExtensions;
|
inline bool koboxExportExtensions;
|
||||||
}
|
} //namespace usbms
|
||||||
namespace settings {
|
namespace settings {
|
||||||
inline bool settingsRebootDialog;
|
inline bool settingsRebootDialog;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,7 @@ namespace global {
|
||||||
inline bool textBrowserDialog;
|
inline bool textBrowserDialog;
|
||||||
inline QString textBrowserContents;
|
inline QString textBrowserContents;
|
||||||
inline QString textBrowserTitle = ""; // At default: empty; "Information" will be displayed
|
inline QString textBrowserTitle = ""; // At default: empty; "Information" will be displayed
|
||||||
}
|
} //namespace text
|
||||||
namespace keyboard {
|
namespace keyboard {
|
||||||
inline bool keyboardDialog;
|
inline bool keyboardDialog;
|
||||||
inline bool keypadDialog;
|
inline bool keypadDialog;
|
||||||
|
@ -101,20 +103,17 @@ namespace global {
|
||||||
inline QString keyboardText;
|
inline QString keyboardText;
|
||||||
inline QString keypadText;
|
inline QString keypadText;
|
||||||
inline bool embed = true;
|
inline bool embed = true;
|
||||||
}
|
} //namespace keyboard
|
||||||
namespace toast {
|
namespace toast {
|
||||||
inline QString message;
|
inline QString message;
|
||||||
inline bool modalToast;
|
inline bool modalToast;
|
||||||
inline bool indefiniteToast;
|
inline bool indefiniteToast;
|
||||||
inline int delay;
|
inline int delay;
|
||||||
}
|
} //namespace toast
|
||||||
namespace device {
|
|
||||||
inline bool isWifiAble;
|
|
||||||
}
|
|
||||||
namespace otaUpdate {
|
namespace otaUpdate {
|
||||||
inline bool isUpdateOta;
|
inline bool isUpdateOta;
|
||||||
inline bool downloadOta;
|
inline bool downloadOta;
|
||||||
}
|
} //namespace otaUpdate
|
||||||
namespace encfs {
|
namespace encfs {
|
||||||
inline QString passphrase;
|
inline QString passphrase;
|
||||||
inline QString unlockTime;
|
inline QString unlockTime;
|
||||||
|
@ -126,7 +125,7 @@ namespace global {
|
||||||
inline bool disableStorageEncryptionDialog;
|
inline bool disableStorageEncryptionDialog;
|
||||||
inline bool errorNoBooksInDropboxDialog;
|
inline bool errorNoBooksInDropboxDialog;
|
||||||
inline bool repackDialog;
|
inline bool repackDialog;
|
||||||
}
|
} //namespace encfs
|
||||||
namespace library {
|
namespace library {
|
||||||
inline unsigned long bookId;
|
inline unsigned long bookId;
|
||||||
inline bool isLatestBook;
|
inline bool isLatestBook;
|
||||||
|
@ -135,7 +134,7 @@ namespace global {
|
||||||
inline bool librarySearchDialog;
|
inline bool librarySearchDialog;
|
||||||
inline bool libraryResults;
|
inline bool libraryResults;
|
||||||
inline bool librarySyncDialog;
|
inline bool librarySyncDialog;
|
||||||
}
|
} //namespace library
|
||||||
namespace bookInfoDialog {
|
namespace bookInfoDialog {
|
||||||
inline bool localInfoDialog;
|
inline bool localInfoDialog;
|
||||||
}
|
}
|
||||||
|
@ -157,8 +156,8 @@ namespace global {
|
||||||
inline bool bookPinAction;
|
inline bool bookPinAction;
|
||||||
inline QString folderPath;
|
inline QString folderPath;
|
||||||
inline bool isFolder = false;
|
inline bool isFolder = false;
|
||||||
}
|
} //namespace bookOptionsDialog
|
||||||
}
|
} //namespace localLibrary
|
||||||
namespace localStorage {
|
namespace localStorage {
|
||||||
inline QStringList searchResultsPaths;
|
inline QStringList searchResultsPaths;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ namespace global {
|
||||||
inline bool appCompatibilityLastContinueStatus = true; // This is for RequiredFeatures to show only one dialog if 'Cancel' is clicked.
|
inline bool appCompatibilityLastContinueStatus = true; // This is for RequiredFeatures to show only one dialog if 'Cancel' is clicked.
|
||||||
inline bool appInfoDialog;
|
inline bool appInfoDialog;
|
||||||
inline bool launchApp;
|
inline bool launchApp;
|
||||||
}
|
} //namespace userApps
|
||||||
namespace homePageWidget {
|
namespace homePageWidget {
|
||||||
static inline int recentBooksNumber = 8;
|
static inline int recentBooksNumber = 8;
|
||||||
static inline int recentBooksNumberPerRow = 4;
|
static inline int recentBooksNumberPerRow = 4;
|
||||||
|
@ -179,7 +178,7 @@ namespace global {
|
||||||
static inline int pinnedBooksNumber = 4;
|
static inline int pinnedBooksNumber = 4;
|
||||||
static inline int pinnedBooksNumberPerRow = 4;
|
static inline int pinnedBooksNumberPerRow = 4;
|
||||||
static inline int pinnedBooksRowNumber = global::homePageWidget::pinnedBooksNumber / global::homePageWidget::pinnedBooksNumberPerRow;
|
static inline int pinnedBooksRowNumber = global::homePageWidget::pinnedBooksNumber / global::homePageWidget::pinnedBooksNumberPerRow;
|
||||||
}
|
} //namespace homePageWidget
|
||||||
namespace highlightsListDialog {
|
namespace highlightsListDialog {
|
||||||
inline QString bookPath;
|
inline QString bookPath;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +197,7 @@ namespace global {
|
||||||
bool encryption;
|
bool encryption;
|
||||||
int signal;
|
int signal;
|
||||||
};
|
};
|
||||||
}
|
} //namespace wifi
|
||||||
namespace audio {
|
namespace audio {
|
||||||
inline bool enabled = false;
|
inline bool enabled = false;
|
||||||
struct musicFile {
|
struct musicFile {
|
||||||
|
@ -229,33 +228,17 @@ namespace global {
|
||||||
inline bool firstScan = true;
|
inline bool firstScan = true;
|
||||||
inline int volumeLevel = 40; // Default save value
|
inline int volumeLevel = 40; // Default save value
|
||||||
inline bool songChanged = false;
|
inline bool songChanged = false;
|
||||||
}
|
} //namespace audio
|
||||||
namespace telemetry {
|
namespace telemetry {
|
||||||
inline bool enabled = false;
|
inline bool enabled = false;
|
||||||
inline bool telemetryDialog = false;
|
inline bool telemetryDialog = false;
|
||||||
}
|
} //namespace telemetry
|
||||||
inline QString systemInfoText;
|
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
inline bool isN705 = false;
|
|
||||||
inline bool isN905C = false;
|
|
||||||
inline bool isN613 = false;
|
|
||||||
inline bool isN873 = false;
|
|
||||||
inline bool isN236 = false;
|
|
||||||
inline bool isN437 = false;
|
|
||||||
inline bool isN306 = false;
|
|
||||||
inline bool isN249 = false;
|
|
||||||
inline bool isKT = false;
|
|
||||||
inline bool runningInstanceIsReaderOnly;
|
inline bool runningInstanceIsReaderOnly;
|
||||||
inline QString deviceID;
|
} //namespace global
|
||||||
}
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534
|
||||||
namespace {
|
namespace {
|
||||||
QString deviceUID;
|
|
||||||
QString device;
|
|
||||||
QString batteryLevel;
|
|
||||||
QString kernelVersion;
|
|
||||||
int batteryLevelInt;
|
|
||||||
int defaultEpubPageWidth;
|
int defaultEpubPageWidth;
|
||||||
int defaultEpubPageHeight;
|
int defaultEpubPageHeight;
|
||||||
int defaultPdfPageWidth;
|
int defaultPdfPageWidth;
|
||||||
|
@ -302,13 +285,12 @@ namespace {
|
||||||
config.close();
|
config.close();
|
||||||
if (content.contains("true")) {
|
if (content.contains("true")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Warning: File '" + file + "' doesn't exist, returning false", "functions");
|
log(function + ": Warning: File '" + file + "' doesn't exist, returning false", "functions");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -316,48 +298,7 @@ namespace {
|
||||||
void setDefaultWorkDir() {
|
void setDefaultWorkDir() {
|
||||||
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
QDir::setCurrent("/mnt/onboard/.adds/inkbox");
|
||||||
}
|
}
|
||||||
int brightnessCheckconfig(QString file) {
|
|
||||||
if(QFile::exists(file)) {
|
|
||||||
QFile config(file);
|
|
||||||
config.open(QIODevice::ReadWrite);
|
|
||||||
QTextStream in (&config);
|
|
||||||
const QString content = in.readAll();
|
|
||||||
int contentInt = content.toInt();
|
|
||||||
return contentInt;
|
|
||||||
config.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void setBrightness(int value) {
|
|
||||||
if(global::deviceID == "n249\n") {
|
|
||||||
if(QFile::exists("/var/run/brightness_write")) {
|
|
||||||
std::ofstream fhandler;
|
|
||||||
fhandler.open("/var/run/brightness_write");
|
|
||||||
fhandler << value;
|
|
||||||
fhandler.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(QFile::exists("/var/run/brightness")) {
|
|
||||||
std::ofstream fhandler;
|
|
||||||
fhandler.open("/var/run/brightness");
|
|
||||||
fhandler << value;
|
|
||||||
fhandler.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void setBrightness_ntxio(int value) {
|
|
||||||
// Thanks to Kevin Short for this (GloLight)
|
|
||||||
int light;
|
|
||||||
if((light = open("/dev/ntx_io", O_RDWR)) == -1) {
|
|
||||||
fprintf(stderr, "Error opening ntx_io device\n");
|
|
||||||
}
|
|
||||||
ioctl(light, 241, value);
|
|
||||||
close(light);
|
|
||||||
}
|
|
||||||
int displayQuote() {
|
int displayQuote() {
|
||||||
int quoteNumber = QRandomGenerator::global()->bounded(1, 6);
|
int quoteNumber = QRandomGenerator::global()->bounded(1, 6);
|
||||||
return quoteNumber;
|
return quoteNumber;
|
||||||
|
@ -368,9 +309,9 @@ namespace {
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
stream << content;
|
stream << content;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Failed to write string '" + content + "' to file '" + filename + "'", "functions");
|
log(function + ": Failed to write string '" + content + "' to file '" + filename + "'", "functions");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,103 +322,11 @@ namespace {
|
||||||
QTextStream in(&fileToRead);
|
QTextStream in(&fileToRead);
|
||||||
QString content = in.readAll();
|
QString content = in.readAll();
|
||||||
return content;
|
return content;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void brightnessWriteconfig(int value) {
|
|
||||||
std::ofstream fhandler;
|
|
||||||
fhandler.open(".config/03-brightness/config");
|
|
||||||
fhandler << value;
|
|
||||||
fhandler.close();
|
|
||||||
}
|
|
||||||
void warmthWriteconfig(int value) {
|
|
||||||
std::ofstream fhandler;
|
|
||||||
fhandler.open(".config/03-brightness/config-warmth");
|
|
||||||
fhandler << value;
|
|
||||||
fhandler.close();
|
|
||||||
}
|
|
||||||
int getBrightness() {
|
|
||||||
if(global::deviceID == "n613\n") {
|
|
||||||
QString brightnessConfig = readFile(".config/03-brightness/config");
|
|
||||||
int brightness;
|
|
||||||
if(brightnessConfig.isEmpty()) {
|
|
||||||
brightness = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
brightness = brightnessConfig.toInt();
|
|
||||||
}
|
|
||||||
return brightness;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(QFile::exists("/var/run/brightness")) {
|
|
||||||
QFile brightness("/var/run/brightness");
|
|
||||||
brightness.open(QIODevice::ReadOnly);
|
|
||||||
QString valuestr = brightness.readAll();
|
|
||||||
int value = valuestr.toInt();
|
|
||||||
brightness.close();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
QString getPowerSupplyOfType(QString type) {
|
|
||||||
QDirIterator supplies("/sys/class/power_supply", QDirIterator::NoIteratorFlags);
|
|
||||||
while(supplies.hasNext()) {
|
|
||||||
supplies.next();
|
|
||||||
QString supply = supplies.filePath();
|
|
||||||
// Badly-classified device by some ntx kernels, ignore
|
|
||||||
if ((type == "Battery") &&
|
|
||||||
(supplies.fileName() == "mc13892_charger")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (readFile(supplies.filePath() + "/type").trimmed() == type) {
|
|
||||||
return supply;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
QString getBatteryFile() {
|
|
||||||
static QString capacity;
|
|
||||||
if (capacity.isNull()) {
|
|
||||||
QString battery = getPowerSupplyOfType("Battery");
|
|
||||||
if (!battery.isNull()) {
|
|
||||||
capacity = battery + "/capacity";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return capacity;
|
|
||||||
}
|
|
||||||
void getBatteryLevel() {
|
|
||||||
batteryLevelInt = 100;
|
|
||||||
batteryLevel = "100%";
|
|
||||||
if(global::deviceID == "kt\n") {
|
|
||||||
if(QFile::exists("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity")) {
|
|
||||||
batteryLevel = readFile("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_capacity").trimmed();
|
|
||||||
batteryLevelInt = batteryLevel.toInt();
|
|
||||||
batteryLevel.append("%");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// probably superfluous, catched by default
|
|
||||||
if(QFile::exists("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity")) {
|
|
||||||
batteryLevel = readFile("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity").trimmed();
|
|
||||||
batteryLevelInt = batteryLevel.toInt();
|
|
||||||
batteryLevel.append("%");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QString path = getBatteryFile();
|
|
||||||
if(QFile::exists(path)) {
|
|
||||||
batteryLevel = readFile(path).trimmed();
|
|
||||||
batteryLevelInt = batteryLevel.toInt();
|
|
||||||
batteryLevel.append("%");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void writeconfig(std::string file, std::string config) {
|
void writeconfig(std::string file, std::string config) {
|
||||||
std::ofstream fhandler;
|
std::ofstream fhandler;
|
||||||
fhandler.open(file);
|
fhandler.open(file);
|
||||||
|
@ -498,43 +347,12 @@ namespace {
|
||||||
|
|
||||||
if (std::regex_search(contentstr, m, r)) {
|
if (std::regex_search(contentstr, m, r)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
bool isBatteryLow() {
|
|
||||||
// Checks if battery level is under 15% of total capacity.
|
|
||||||
getBatteryLevel();
|
|
||||||
if(batteryLevelInt <= 15) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
bool isBatteryCritical() {
|
|
||||||
// Checks if the battery level is critical (i.e. <= 5%)
|
|
||||||
getBatteryLevel();
|
|
||||||
if(batteryLevelInt <= 5) {
|
|
||||||
QString function = __func__; log(function + ": Battery is at a critical charge level!", "functions");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void zeroBrightness() {
|
|
||||||
if(global::deviceID != "n613\n") {
|
|
||||||
setBrightness(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setBrightness_ntxio(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void poweroff(bool splash) {
|
void poweroff(bool splash) {
|
||||||
log("Powering off", "functions");
|
log("Powering off", "functions");
|
||||||
if (splash == true) {
|
if (splash == true) {
|
||||||
|
@ -544,8 +362,7 @@ namespace {
|
||||||
proc->start(prog, args);
|
proc->start(prog, args);
|
||||||
proc->waitForFinished();
|
proc->waitForFinished();
|
||||||
proc->deleteLater();
|
proc->deleteLater();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QString prog("/sbin/poweroff");
|
QString prog("/sbin/poweroff");
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "no_splash";
|
args << "no_splash";
|
||||||
|
@ -561,20 +378,20 @@ namespace {
|
||||||
QString prog("/sbin/reboot");
|
QString prog("/sbin/reboot");
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if (global::kobox::resetKoboxUserDataBool == true) {
|
if (global::kobox::resetKoboxUserDataBool == true) {
|
||||||
args << "splash" << "reset_kobox";
|
args << "splash"
|
||||||
|
<< "reset_kobox";
|
||||||
}
|
}
|
||||||
QProcess *proc = new QProcess();
|
QProcess *proc = new QProcess();
|
||||||
proc->start(prog, args);
|
proc->start(prog, args);
|
||||||
proc->waitForFinished();
|
proc->waitForFinished();
|
||||||
proc->deleteLater();
|
proc->deleteLater();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QString prog("/sbin/reboot");
|
QString prog("/sbin/reboot");
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if (global::kobox::resetKoboxUserDataBool == true) {
|
if (global::kobox::resetKoboxUserDataBool == true) {
|
||||||
args << "no_splash" << "reset_kobox";
|
args << "no_splash"
|
||||||
}
|
<< "reset_kobox";
|
||||||
else {
|
} else {
|
||||||
args << "no_splash";
|
args << "no_splash";
|
||||||
}
|
}
|
||||||
QProcess *proc = new QProcess();
|
QProcess *proc = new QProcess();
|
||||||
|
@ -583,57 +400,14 @@ namespace {
|
||||||
proc->deleteLater();
|
proc->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString getUID() {
|
|
||||||
QString prog ("dd");
|
|
||||||
QStringList args;
|
|
||||||
args << "if=/dev/mmcblk0" << "bs=512" << "skip=1" << "count=1" << "status=none";
|
|
||||||
QProcess *proc = new QProcess();
|
|
||||||
proc->start(prog, args);
|
|
||||||
proc->waitForFinished();
|
|
||||||
|
|
||||||
deviceUID = proc->readAllStandardOutput();
|
|
||||||
deviceUID = deviceUID.left(256);
|
|
||||||
|
|
||||||
proc->deleteLater();
|
|
||||||
|
|
||||||
return deviceUID;
|
|
||||||
}
|
|
||||||
void getKernelVersion() {
|
|
||||||
QString prog ("uname");
|
|
||||||
QStringList args;
|
|
||||||
args << "-r";
|
|
||||||
QProcess *proc = new QProcess();
|
|
||||||
proc->start(prog, args);
|
|
||||||
proc->waitForFinished();
|
|
||||||
|
|
||||||
kernelVersion = proc->readAllStandardOutput();
|
|
||||||
kernelVersion = kernelVersion.trimmed();
|
|
||||||
|
|
||||||
proc->deleteLater();
|
|
||||||
|
|
||||||
setDefaultWorkDir();
|
|
||||||
writeFile("/external_root/run/initrd-fifo", "get_kernel_build_id\n");
|
|
||||||
QThread::msleep(100);
|
|
||||||
writeFile("/external_root/run/initrd-fifo", "get_kernel_commit\n");
|
|
||||||
QThread::msleep(100);
|
|
||||||
|
|
||||||
QString kernelBuildID = readFile("/external_root/run/kernel_build_id").trimmed();
|
|
||||||
kernelVersion.append(", build ");
|
|
||||||
kernelVersion.append(kernelBuildID);
|
|
||||||
|
|
||||||
QString kernelCommit = readFile("/external_root/run/kernel_commit").trimmed();
|
|
||||||
kernelVersion.append(", commit ");
|
|
||||||
kernelVersion.append(kernelCommit);
|
|
||||||
}
|
|
||||||
QString getConnectionInformation() {
|
QString getConnectionInformation() {
|
||||||
QString getIpProg("sh");
|
QString getIpProg("sh");
|
||||||
QStringList getIpArgs;
|
QStringList getIpArgs;
|
||||||
if(global::deviceID != "n437\n" and global::deviceID != "n249\n") {
|
|
||||||
getIpArgs << "-c" << "/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'";
|
getIpArgs << "-c"
|
||||||
}
|
<< "/sbin/ifconfig " + Device::getSingleton()->getNetworkInterfaceName() + " | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'";
|
||||||
else {
|
|
||||||
getIpArgs << "-c" << "/sbin/ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'";
|
|
||||||
}
|
|
||||||
QProcess *getIpProc = new QProcess();
|
QProcess *getIpProc = new QProcess();
|
||||||
getIpProc->start(getIpProg, getIpArgs);
|
getIpProc->start(getIpProg, getIpArgs);
|
||||||
getIpProc->waitForFinished();
|
getIpProc->waitForFinished();
|
||||||
|
@ -646,26 +420,7 @@ namespace {
|
||||||
getIpProc->deleteLater();
|
getIpProc->deleteLater();
|
||||||
return ipAddress;
|
return ipAddress;
|
||||||
}
|
}
|
||||||
void getSystemInfo() {
|
|
||||||
getUID();
|
|
||||||
getKernelVersion();
|
|
||||||
global::systemInfoText = "<b>InkBox OS version ";
|
|
||||||
global::systemInfoText.append(readFile("/external_root/opt/isa/version"));
|
|
||||||
global::systemInfoText.append("</b><br>Copyright <font face='Inter'>©</font> 2021-2024 Nicolas Mailloux and contributors<br>Special thanks to: Szybet, NiLuJe, akemnade, Rain92 (GitHub)");
|
|
||||||
global::systemInfoText.append("<br><b>GUI Git commit:</b> ");
|
|
||||||
global::systemInfoText.append(GIT_VERSION);
|
|
||||||
global::systemInfoText.append("<br><b>Device UID:</b> ");
|
|
||||||
global::systemInfoText.append(deviceUID);
|
|
||||||
global::systemInfoText.append("<br><b>Kernel version:</b> ");
|
|
||||||
global::systemInfoText.append(kernelVersion);
|
|
||||||
global::systemInfoText.append("<br><b>Device:</b> ");
|
|
||||||
QString device = global::deviceID.trimmed();
|
|
||||||
global::systemInfoText.append(device);
|
|
||||||
QString ipAddress = getConnectionInformation();
|
|
||||||
global::systemInfoText.append("<br><b>IP address: </b>");
|
|
||||||
global::systemInfoText.append(ipAddress);
|
|
||||||
|
|
||||||
}
|
|
||||||
void resetKoboxUserData() {
|
void resetKoboxUserData() {
|
||||||
log("Resetting KoBox user data", "functions");
|
log("Resetting KoBox user data", "functions");
|
||||||
global::kobox::resetKoboxUserDataBool = true;
|
global::kobox::resetKoboxUserDataBool = true;
|
||||||
|
@ -682,7 +437,8 @@ namespace {
|
||||||
proc->waitForFinished();
|
proc->waitForFinished();
|
||||||
|
|
||||||
QString returnedMetadata = proc->readAllStandardOutput();
|
QString returnedMetadata = proc->readAllStandardOutput();
|
||||||
QString function = __func__; log(function + ": ePUB metadata is: " + returnedMetadata, "functions");
|
QString function = __func__;
|
||||||
|
log(function + ": ePUB metadata is: " + returnedMetadata, "functions");
|
||||||
return returnedMetadata;
|
return returnedMetadata;
|
||||||
}
|
}
|
||||||
void defineDefaultPageSize(int fileType) {
|
void defineDefaultPageSize(int fileType) {
|
||||||
|
@ -690,64 +446,56 @@ namespace {
|
||||||
* 0: ePUB
|
* 0: ePUB
|
||||||
* 1: PDF
|
* 1: PDF
|
||||||
*/
|
*/
|
||||||
|
Device *device = Device::getSingleton();
|
||||||
|
Device::ScreenSize screenSize = device->getScreenSize();
|
||||||
|
|
||||||
if (fileType == 0) {
|
if (fileType == 0) {
|
||||||
if(global::deviceID == "n705\n") {
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
defaultEpubPageHeight = 365;
|
defaultEpubPageHeight = 365;
|
||||||
defaultEpubPageWidth = 365;
|
defaultEpubPageWidth = 365;
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
defaultEpubPageHeight = 425;
|
defaultEpubPageHeight = 425;
|
||||||
defaultEpubPageWidth = 425;
|
defaultEpubPageWidth = 425;
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::LARGE) {
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "n249\n" or global::deviceID == "emu\n") {
|
|
||||||
defaultEpubPageHeight = 450;
|
defaultEpubPageHeight = 450;
|
||||||
defaultEpubPageWidth = 450;
|
defaultEpubPageWidth = 450;
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::VERY_LARGE) {
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
defaultEpubPageHeight = 525;
|
defaultEpubPageHeight = 525;
|
||||||
defaultEpubPageWidth = 525;
|
defaultEpubPageWidth = 525;
|
||||||
}
|
}
|
||||||
QString function = __func__;
|
QString function = __func__;
|
||||||
log(function + ": Defined default ePUB page height to " + QString::number(defaultEpubPageHeight), "functions");
|
log(function + ": Defined default ePUB page height to " + QString::number(defaultEpubPageHeight), "functions");
|
||||||
log(function + ": Defined default ePUB page width to " + QString::number(defaultEpubPageWidth), "functions");
|
log(function + ": Defined default ePUB page width to " + QString::number(defaultEpubPageWidth), "functions");
|
||||||
}
|
} else if (fileType == 1) {
|
||||||
else if(fileType == 1) {
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
if (global::reader::pdfOrientation == 0) {
|
if (global::reader::pdfOrientation == 0) {
|
||||||
defaultPdfPageHeight = 750;
|
defaultPdfPageHeight = 750;
|
||||||
defaultPdfPageWidth = 550;
|
defaultPdfPageWidth = 550;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultPdfPageHeight = 550;
|
defaultPdfPageHeight = 550;
|
||||||
defaultPdfPageWidth = 750;
|
defaultPdfPageWidth = 750;
|
||||||
}
|
}
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
|
||||||
if (global::reader::pdfOrientation == 0) {
|
if (global::reader::pdfOrientation == 0) {
|
||||||
defaultPdfPageHeight = 974;
|
defaultPdfPageHeight = 974;
|
||||||
defaultPdfPageWidth = 708;
|
defaultPdfPageWidth = 708;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultPdfPageHeight = 708;
|
defaultPdfPageHeight = 708;
|
||||||
defaultPdfPageWidth = 974;
|
defaultPdfPageWidth = 974;
|
||||||
}
|
}
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::LARGE) {
|
||||||
else if(global::deviceID == "n437\n" or global::deviceID == "n249\n") {
|
|
||||||
if (global::reader::pdfOrientation == 0) {
|
if (global::reader::pdfOrientation == 0) {
|
||||||
defaultPdfPageHeight = 1398;
|
defaultPdfPageHeight = 1398;
|
||||||
defaultPdfPageWidth = 1022;
|
defaultPdfPageWidth = 1022;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultPdfPageHeight = 1022;
|
defaultPdfPageHeight = 1022;
|
||||||
defaultPdfPageWidth = 1398;
|
defaultPdfPageWidth = 1398;
|
||||||
}
|
}
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::VERY_LARGE) {
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
if (global::reader::pdfOrientation == 0) {
|
if (global::reader::pdfOrientation == 0) {
|
||||||
defaultPdfPageHeight = 1630;
|
defaultPdfPageHeight = 1630;
|
||||||
defaultPdfPageWidth = 1214;
|
defaultPdfPageWidth = 1214;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
defaultPdfPageHeight = 1214;
|
defaultPdfPageHeight = 1214;
|
||||||
defaultPdfPageWidth = 1630;
|
defaultPdfPageWidth = 1630;
|
||||||
}
|
}
|
||||||
|
@ -757,108 +505,7 @@ namespace {
|
||||||
log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions");
|
log(function + "Defined default PDF page width to " + QString::number(defaultPdfPageWidth), "functions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void preSetBrightness(int brightnessValue) {
|
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "n873\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "n249\n" or global::deviceID == "kt\n") {
|
|
||||||
setBrightness(brightnessValue);
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n") {
|
|
||||||
setBrightness_ntxio(brightnessValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setBrightness(brightnessValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void cinematicBrightness(int value, int mode) {
|
|
||||||
/* mode can be 0, 1, or 2, respectively:
|
|
||||||
* 0: Bring UP brightness
|
|
||||||
* 1: Bring DOWN brightness
|
|
||||||
* 2: Auto; smooth brightness transition between two brightness levels
|
|
||||||
*/
|
|
||||||
if(global::deviceID != "n705\n" && global::deviceID != "n905\n" && global::deviceID != "kt\n") {
|
|
||||||
QString function = __func__; log(function + ": Setting brightness to " + QString::number(value), "functions");
|
|
||||||
}
|
|
||||||
if(mode == 0) {
|
|
||||||
int brightness = 0;
|
|
||||||
while(brightness != value) {
|
|
||||||
brightness = brightness + 1;
|
|
||||||
preSetBrightness(brightness);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(mode == 1) {
|
|
||||||
int brightness = getBrightness();
|
|
||||||
while(brightness != 0) {
|
|
||||||
brightness = brightness - 1;
|
|
||||||
preSetBrightness(brightness);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(mode == 2) {
|
|
||||||
int brightness = getBrightness();
|
|
||||||
if(brightness <= value) {
|
|
||||||
while(brightness != value) {
|
|
||||||
brightness = brightness + 1;
|
|
||||||
preSetBrightness(brightness);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(brightness >= value) {
|
|
||||||
while(brightness != value) {
|
|
||||||
brightness = brightness - 1;
|
|
||||||
preSetBrightness(brightness);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int getWarmth() {
|
|
||||||
QString sysfsWarmthPath;
|
|
||||||
int warmthValue;
|
|
||||||
if(global::deviceID == "n873\n") {
|
|
||||||
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n249\n") {
|
|
||||||
sysfsWarmthPath = "/sys/class/backlight/backlight_warm/actual_brightness";
|
|
||||||
}
|
|
||||||
QString warmthConfig = readFile(sysfsWarmthPath);
|
|
||||||
warmthValue = warmthConfig.toInt();
|
|
||||||
if (global::deviceID == "n873\n") {
|
|
||||||
warmthValue = 10 - warmthValue;
|
|
||||||
}
|
|
||||||
return warmthValue;
|
|
||||||
}
|
|
||||||
void setWarmth(int warmthValue) {
|
|
||||||
QString sysfsWarmthPath;
|
|
||||||
QString warmthValueStr;
|
|
||||||
if(global::deviceID == "n873\n") {
|
|
||||||
// Value 0 gives a warmer lighting than value 10
|
|
||||||
warmthValue = 10 - warmthValue;
|
|
||||||
warmthValueStr = QString::number(warmthValue);
|
|
||||||
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n249\n") {
|
|
||||||
warmthValueStr = QString::number(warmthValue);
|
|
||||||
sysfsWarmthPath = "/sys/class/backlight/backlight_warm/brightness";
|
|
||||||
}
|
|
||||||
writeFile(sysfsWarmthPath, warmthValueStr);
|
|
||||||
}
|
|
||||||
void cinematicWarmth(int warmthValue) {
|
|
||||||
int currentWarmth = getWarmth();
|
|
||||||
if(warmthValue < currentWarmth) {
|
|
||||||
while(warmthValue < currentWarmth) {
|
|
||||||
currentWarmth--;
|
|
||||||
setWarmth(currentWarmth);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(warmthValue > currentWarmth) {
|
|
||||||
while(warmthValue > currentWarmth) {
|
|
||||||
currentWarmth++;
|
|
||||||
setWarmth(currentWarmth);
|
|
||||||
QThread::msleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void installUpdate() {
|
void installUpdate() {
|
||||||
log("Installing update package", "functions");
|
log("Installing update package", "functions");
|
||||||
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n");
|
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n");
|
||||||
|
@ -869,43 +516,14 @@ namespace {
|
||||||
bool getEncFSStatus() {
|
bool getEncFSStatus() {
|
||||||
return checkconfig("/external_root/run/encfs_mounted");
|
return checkconfig("/external_root/run/encfs_mounted");
|
||||||
}
|
}
|
||||||
bool isUsbPluggedIn() {
|
|
||||||
if(global::deviceID == "kt\n") {
|
|
||||||
if(readFile("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_status") == "1\n") {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n249\n") {
|
|
||||||
if(readFile("/sys/class/power_supply/rn5t618-battery/status") != "Discharging\n") {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Thanks to https://github.com/koreader/KoboUSBMS/blob/2efdf9d920c68752b2933f21c664dc1afb28fc2e/usbms.c#L148-L158
|
|
||||||
int ntxfd;
|
|
||||||
if((ntxfd = open("/dev/ntx_io", O_RDWR)) == -1) {
|
|
||||||
fprintf(stderr, "Error opening ntx_io device\n");
|
|
||||||
}
|
|
||||||
unsigned long ptr = 0U;
|
|
||||||
ioctl(ntxfd, 108, &ptr);
|
|
||||||
close(ntxfd);
|
|
||||||
return !!ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void updateUserAppsMainJsonFile() {
|
void updateUserAppsMainJsonFile() {
|
||||||
QDirIterator appsDir("/mnt/onboard/onboard/.apps", QDirIterator::NoIteratorFlags);
|
QDirIterator appsDir("/mnt/onboard/onboard/.apps", QDirIterator::NoIteratorFlags);
|
||||||
QFile newJsonFile = QFile{ "/mnt/onboard/onboard/.apps/apps.json" };
|
QFile newJsonFile = QFile{ "/mnt/onboard/onboard/.apps/apps.json" };
|
||||||
QJsonDocument newJsonDocument;
|
QJsonDocument newJsonDocument;
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
|
|
||||||
while (appsDir.hasNext())
|
while (appsDir.hasNext()) {
|
||||||
{
|
|
||||||
QDir dir(appsDir.next());
|
QDir dir(appsDir.next());
|
||||||
if (dir.exists() == true) {
|
if (dir.exists() == true) {
|
||||||
if (dir.path().split("/").last().contains(".") == false) {
|
if (dir.path().split("/").last().contains(".") == false) {
|
||||||
|
@ -920,13 +538,11 @@ namespace {
|
||||||
QJsonObject jsonSmallMainObj = jsonSmallDoc["app"].toObject();
|
QJsonObject jsonSmallMainObj = jsonSmallDoc["app"].toObject();
|
||||||
array.append(jsonSmallMainObj);
|
array.append(jsonSmallMainObj);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Error: User application '" + appsDir.path() + "''s JSON file descriptor is missing main object 'app'", "main");
|
log("Error: User application '" + appsDir.path() + "''s JSON file descriptor is missing main object 'app'", "main");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QString message = "User application '" + appsDir.path() + "' does not contain any 'app.json' file: ";
|
QString message = "User application '" + appsDir.path() + "' does not contain any 'app.json' file: ";
|
||||||
message.append(jsonSmall.fileName());
|
message.append(jsonSmall.fileName());
|
||||||
log(message, "main");
|
log(message, "main");
|
||||||
|
@ -965,7 +581,8 @@ namespace {
|
||||||
if (dir.exists() == true) {
|
if (dir.exists() == true) {
|
||||||
if (dir.path().split("/").last().toLower().contains(appName.toLower()) == true) {
|
if (dir.path().split("/").last().toLower().contains(appName.toLower()) == true) {
|
||||||
QJsonObject root;
|
QJsonObject root;
|
||||||
root["app"] = refJsonObject.toObject();;
|
root["app"] = refJsonObject.toObject();
|
||||||
|
;
|
||||||
QJsonDocument newJsonDocument;
|
QJsonDocument newJsonDocument;
|
||||||
newJsonDocument.setObject(root);
|
newJsonDocument.setObject(root);
|
||||||
|
|
||||||
|
@ -998,9 +615,9 @@ namespace {
|
||||||
if (database.open(QIODevice::ReadOnly)) {
|
if (database.open(QIODevice::ReadOnly)) {
|
||||||
data = database.readAll();
|
data = database.readAll();
|
||||||
database.close();
|
database.close();
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Failed to open local library database file for reading at '" + database.fileName() + "'", "functions");
|
log(function + ": Failed to open local library database file for reading at '" + database.fileName() + "'", "functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse JSON data
|
// Parse JSON data
|
||||||
|
@ -1015,9 +632,9 @@ namespace {
|
||||||
if (database.open(QIODevice::ReadOnly)) {
|
if (database.open(QIODevice::ReadOnly)) {
|
||||||
data = database.readAll();
|
data = database.readAll();
|
||||||
database.close();
|
database.close();
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Failed to open highlights database file for reading at '" + database.fileName() + "'", "functions");
|
log(function + ": Failed to open highlights database file for reading at '" + database.fileName() + "'", "functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse JSON data
|
// Parse JSON data
|
||||||
|
@ -1034,9 +651,9 @@ namespace {
|
||||||
if (database.open(QIODevice::ReadOnly)) {
|
if (database.open(QIODevice::ReadOnly)) {
|
||||||
data = database.readAll();
|
data = database.readAll();
|
||||||
database.close();
|
database.close();
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Failed to open To-Do database file for reading at '" + database.fileName() + "'", "functions");
|
log(function + ": Failed to open To-Do database file for reading at '" + database.fileName() + "'", "functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse JSON data
|
// Parse JSON data
|
||||||
|
@ -1055,8 +672,7 @@ namespace {
|
||||||
firstJsonObject.insert("T-" + QUuid::createUuid().toString(QUuid::WithoutBraces), QJsonValue(text));
|
firstJsonObject.insert("T-" + QUuid::createUuid().toString(QUuid::WithoutBraces), QJsonValue(text));
|
||||||
mainJsonObject["Book1"] = firstJsonObject;
|
mainJsonObject["Book1"] = firstJsonObject;
|
||||||
writeHighlightsDatabase(mainJsonObject);
|
writeHighlightsDatabase(mainJsonObject);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QJsonObject jsonObject = readHighlightsDatabase();
|
QJsonObject jsonObject = readHighlightsDatabase();
|
||||||
bool highlightWrote = false;
|
bool highlightWrote = false;
|
||||||
int length = jsonObject.length();
|
int length = jsonObject.length();
|
||||||
|
@ -1072,8 +688,7 @@ namespace {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (highlightJsonObject.contains(uuid)) {
|
if (highlightJsonObject.contains(uuid)) {
|
||||||
uuid = "T-" + QUuid::createUuid().toString(QUuid::WithoutBraces);
|
uuid = "T-" + QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,8 +712,7 @@ namespace {
|
||||||
highlightWrote = true;
|
highlightWrote = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QJsonObject jsonObject = readHighlightsDatabase();
|
QJsonObject jsonObject = readHighlightsDatabase();
|
||||||
int length = jsonObject.length();
|
int length = jsonObject.length();
|
||||||
for (int i = 1; i <= length; i++) {
|
for (int i = 1; i <= length; i++) {
|
||||||
|
@ -1128,27 +742,19 @@ namespace {
|
||||||
return QJsonObject();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
float determineYIncrease() {
|
float determineYIncrease() {
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
Device::ScreenSize screenSize = Device::getSingleton()->getScreenSize();
|
||||||
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
} else if (screenSize <= Device::ScreenSize::LARGE) {
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
|
||||||
return 2.6;
|
return 2.6;
|
||||||
}
|
} else if (screenSize == Device::ScreenSize::VERY_LARGE) {
|
||||||
else if(global::deviceID == "n437\n" or global::deviceID == "n249\n" or global::deviceID == "n873\n") {
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
global::wifi::wifiState checkWifiState() {
|
global::wifi::wifiState checkWifiState() {
|
||||||
QString interfaceName;
|
QString interfaceName = Device::getSingleton()->getNetworkInterfaceName();
|
||||||
if(global::deviceID == "n437\n" or global::deviceID == "n249\n" or global::deviceID == "kt\n") {
|
|
||||||
interfaceName = "wlan0";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
interfaceName = "eth0";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if network interface has an IP address
|
// Check if network interface has an IP address
|
||||||
QNetworkInterface iface = QNetworkInterface::interfaceFromName(interfaceName);
|
QNetworkInterface iface = QNetworkInterface::interfaceFromName(interfaceName);
|
||||||
|
@ -1157,14 +763,12 @@ namespace {
|
||||||
// Interface is up and has an IP address
|
// Interface is up and has an IP address
|
||||||
global::wifi::isConnected = true;
|
global::wifi::isConnected = true;
|
||||||
return global::wifi::wifiState::configured;
|
return global::wifi::wifiState::configured;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (QFile::exists("/sys/class/net/" + interfaceName + "/operstate")) {
|
if (QFile::exists("/sys/class/net/" + interfaceName + "/operstate")) {
|
||||||
// Interface is up but doesn't have an IP address
|
// Interface is up but doesn't have an IP address
|
||||||
global::wifi::isConnected = false;
|
global::wifi::isConnected = false;
|
||||||
return global::wifi::wifiState::enabled;
|
return global::wifi::wifiState::enabled;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Interface is not up
|
// Interface is not up
|
||||||
global::wifi::isConnected = false;
|
global::wifi::isConnected = false;
|
||||||
return global::wifi::wifiState::disabled;
|
return global::wifi::wifiState::disabled;
|
||||||
|
@ -1173,11 +777,13 @@ namespace {
|
||||||
}
|
}
|
||||||
int testPing(QString ipAddress = "1.1.1.1") {
|
int testPing(QString ipAddress = "1.1.1.1") {
|
||||||
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
||||||
QString function = __func__; log(function + ": pinging IP address " + ipAddress, "functions");
|
QString function = __func__;
|
||||||
|
log(function + ": pinging IP address " + ipAddress, "functions");
|
||||||
QProcess *pingProcess = new QProcess();
|
QProcess *pingProcess = new QProcess();
|
||||||
QString pingProg = "ping";
|
QString pingProg = "ping";
|
||||||
QStringList pingArgs;
|
QStringList pingArgs;
|
||||||
pingArgs << "-c" << "1" << ipAddress;
|
pingArgs << "-c"
|
||||||
|
<< "1" << ipAddress;
|
||||||
pingProcess->start(pingProg, pingArgs);
|
pingProcess->start(pingProg, pingArgs);
|
||||||
pingProcess->waitForFinished();
|
pingProcess->waitForFinished();
|
||||||
int exitCode = pingProcess->exitCode();
|
int exitCode = pingProcess->exitCode();
|
||||||
|
@ -1185,8 +791,7 @@ namespace {
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
log("Ping successful", "functions");
|
log("Ping successful", "functions");
|
||||||
global::wifi::isConnected = true;
|
global::wifi::isConnected = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Ping unsuccessful", "functions");
|
log("Ping unsuccessful", "functions");
|
||||||
if (ipAddress == "1.1.1.1") {
|
if (ipAddress == "1.1.1.1") {
|
||||||
global::wifi::isConnected = false;
|
global::wifi::isConnected = false;
|
||||||
|
@ -1220,8 +825,7 @@ namespace {
|
||||||
QString str;
|
QString str;
|
||||||
if (option == true) {
|
if (option == true) {
|
||||||
str = "true";
|
str = "true";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
str = "false";
|
str = "false";
|
||||||
}
|
}
|
||||||
std::ofstream fhandler;
|
std::ofstream fhandler;
|
||||||
|
@ -1229,6 +833,6 @@ namespace {
|
||||||
fhandler << str.toStdString();
|
fhandler << str.toStdString();
|
||||||
fhandler.close();
|
fhandler.close();
|
||||||
}
|
}
|
||||||
}
|
} //namespace
|
||||||
|
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
File diff suppressed because it is too large
Load diff
151
src/main.cpp
151
src/main.cpp
|
@ -15,25 +15,26 @@
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "alert.h"
|
|
||||||
#include "generaldialog.h"
|
|
||||||
#include "functions.h"
|
|
||||||
#include "reader.h"
|
|
||||||
#include "encryptionmanager.h"
|
|
||||||
#include "sleepthread.h"
|
|
||||||
#include "sleepdialog.h"
|
|
||||||
#include "audiothread.h"
|
#include "audiothread.h"
|
||||||
|
#include "encryptionmanager.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "generaldialog.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "reader.h"
|
||||||
|
#include "sleepdialog.h"
|
||||||
|
#include "sleepthread.h"
|
||||||
|
#include "splashAlert.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
|
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
|
||||||
|
|
||||||
|
@ -43,20 +44,23 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global::deviceID = readFile("/opt/inkbox_device");
|
QString deviceID = readFile("/opt/inkbox_device");
|
||||||
log("Running on device " + global::deviceID, "main", true);
|
if (deviceID.isEmpty()) {
|
||||||
|
// we don't have a device id, assume that this is running in an emu
|
||||||
|
deviceID = "emu";
|
||||||
|
}
|
||||||
|
log("Running on device " + deviceID, "main", true);
|
||||||
|
// initialize the platform singleton
|
||||||
|
Device::setup(deviceID);
|
||||||
|
|
||||||
// Tell the OS that we're currently running
|
// Tell the OS that we're currently running
|
||||||
writeFile("/tmp/inkbox_running", "true");
|
writeFile("/tmp/inkbox_running", "true");
|
||||||
|
|
||||||
setDefaultWorkDir();
|
setDefaultWorkDir();
|
||||||
if(checkconfig("/run/wifi_able") == true) {
|
if (Device::getSingleton()->supportsWifi()) {
|
||||||
log("Device has Wi-Fi capabilities", "main");
|
log("Device has Wi-Fi capabilities", "main");
|
||||||
global::device::isWifiAble = true;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
log("Device does not have Wi-Fi capabilities", "main");
|
log("Device does not have Wi-Fi capabilities", "main");
|
||||||
global::device::isWifiAble = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QFile::exists("/tmp/currentlyRunningUserApplication")) {
|
if (QFile::exists("/tmp/currentlyRunningUserApplication")) {
|
||||||
|
@ -82,8 +86,7 @@ int main(int argc, char *argv[])
|
||||||
QFile::remove("/tmp/gui_apps_started");
|
QFile::remove("/tmp/gui_apps_started");
|
||||||
updateUserAppsMainJsonFile();
|
updateUserAppsMainJsonFile();
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("GUI apps service failed to start", "main");
|
log("GUI apps service failed to start", "main");
|
||||||
QFile::remove("/tmp/gui_apps_started");
|
QFile::remove("/tmp/gui_apps_started");
|
||||||
break;
|
break;
|
||||||
|
@ -95,14 +98,14 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Power daemon-related stuff
|
// Power daemon-related stuff
|
||||||
sleepDialog * sleepDialogWindow = new sleepDialog;
|
SleepDialog *sleepDialogWindow = new SleepDialog;
|
||||||
// https://wiki.qt.io/QThreads_general_usage
|
// https://wiki.qt.io/QThreads_general_usage
|
||||||
QThread *IPDThread = new QThread();
|
QThread *IPDThread = new QThread();
|
||||||
sleepThread * sleepThreadWindow = new sleepThread();
|
SleepThread *sleepThreadWindow = new SleepThread();
|
||||||
sleepThreadWindow->moveToThread(IPDThread);
|
sleepThreadWindow->moveToThread(IPDThread);
|
||||||
QObject::connect(IPDThread, &QThread::started, sleepThreadWindow, &sleepThread::start);
|
QObject::connect(IPDThread, &QThread::started, sleepThreadWindow, &SleepThread::start);
|
||||||
QObject::connect(sleepThreadWindow, &sleepThread::startDialog, sleepDialogWindow, &sleepDialog::launchSleepDialog);
|
QObject::connect(sleepThreadWindow, &SleepThread::startDialog, sleepDialogWindow, &SleepDialog::launchSleepDialog);
|
||||||
QObject::connect(sleepThreadWindow, &sleepThread::stopDialog, sleepDialogWindow, &sleepDialog::hideSleepDialog);
|
QObject::connect(sleepThreadWindow, &SleepThread::stopDialog, sleepDialogWindow, &SleepDialog::hideSleepDialog);
|
||||||
IPDThread->start();
|
IPDThread->start();
|
||||||
|
|
||||||
// Audio stuff
|
// Audio stuff
|
||||||
|
@ -110,42 +113,38 @@ int main(int argc, char *argv[])
|
||||||
log("Audio is enabled", "main");
|
log("Audio is enabled", "main");
|
||||||
global::audio::enabled = true;
|
global::audio::enabled = true;
|
||||||
QThread *audioThread = new QThread();
|
QThread *audioThread = new QThread();
|
||||||
audiothread * audioObject = new audiothread();
|
AudioThread *audioObject = new AudioThread();
|
||||||
audioObject->moveToThread(audioThread);
|
audioObject->moveToThread(audioThread);
|
||||||
QObject::connect(audioThread, &QThread::started, audioObject, &audiothread::start);
|
QObject::connect(audioThread, &QThread::started, audioObject, &AudioThread::start);
|
||||||
audioThread->start();
|
audioThread->start();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Audio is disabled", "main");
|
log("Audio is disabled", "main");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/external_root/run/encfs_mounted") == false) {
|
if (checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/external_root/run/encfs_mounted") == false) {
|
||||||
// Open Encryption Manager to unlock encrypted storage
|
// Open Encryption Manager to unlock encrypted storage
|
||||||
encryptionManager w;
|
CryptoManagerWidget w;
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
} else if (checkconfig("/external_root/run/encfs_mounted") == true and checkconfig("/external_root/run/encfs_repack") == true) {
|
||||||
else if(checkconfig("/external_root/run/encfs_mounted") == true and checkconfig("/external_root/run/encfs_repack") == true) {
|
|
||||||
log("Launching encryptionManager", "main");
|
log("Launching encryptionManager", "main");
|
||||||
encryptionManager w;
|
CryptoManagerWidget w;
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Variables
|
// Variables
|
||||||
global::reader::startBatteryWatchdog = false;
|
global::reader::startBatteryWatchdog = false;
|
||||||
global::reader::startUsbmsPrompt = false;
|
global::reader::startUsbmsPrompt = false;
|
||||||
|
|
||||||
// Checking if battery level is critical; if true (and if it is not charging), then display a "Please charge your eReader" splash and power off.
|
// Checking if battery level is critical; if true (and if it is not charging), then display a "Please charge your eReader" splash and power off.
|
||||||
if(global::deviceID != "emu\n") {
|
if (Device::getSingleton()->getBatteryLevel() <= 5) {
|
||||||
if(isBatteryCritical() == true) {
|
if (!Device::getSingleton()->isUSBPluggedIn()) {
|
||||||
if(!isUsbPluggedIn()) {
|
|
||||||
global::battery::showCriticalBatteryAlert = true;
|
global::battery::showCriticalBatteryAlert = true;
|
||||||
alert w;
|
SplashAlertWidget w;
|
||||||
|
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
|
@ -153,11 +152,10 @@ int main(int argc, char *argv[])
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if there has been an ALERT flag set up, and if there is, show a big warning
|
// Checking if there has been an ALERT flag set up, and if there is, show a big warning
|
||||||
if (checkconfig("/external_root/boot/flags/ALERT") == true) {
|
if (checkconfig("/external_root/boot/flags/ALERT") == true) {
|
||||||
alert w;
|
SplashAlertWidget w;
|
||||||
|
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
|
@ -173,86 +171,21 @@ int main(int argc, char *argv[])
|
||||||
global::reader::skipOpenDialog = true;
|
global::reader::skipOpenDialog = true;
|
||||||
|
|
||||||
writeFile("/inkbox/skip_opendialog", "true");
|
writeFile("/inkbox/skip_opendialog", "true");
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
global::isN705 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n905\n") {
|
|
||||||
global::isN905C = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n") {
|
|
||||||
global::isN613 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
global::isN873 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n236\n") {
|
|
||||||
global::isN236 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n437\n") {
|
|
||||||
global::isN437 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n306\n") {
|
|
||||||
global::isN306 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n249\n") {
|
|
||||||
global::isN249 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "kt\n") {
|
|
||||||
global::isKT = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
reader w;
|
ReaderWidget w;
|
||||||
|
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QProcess::execute("remount_tmpfs_launch.sh", QStringList());
|
QProcess::execute("remount_tmpfs_launch.sh", QStringList());
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
||||||
QApplication::setStyle("windows");
|
QApplication::setStyle("windows");
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
UI::applyStyle(w, "eink");
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
w.setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
global::isN705 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n905\n") {
|
|
||||||
global::isN905C = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n") {
|
|
||||||
global::isN613 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
global::isN873 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n236\n") {
|
|
||||||
global::isN236 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n437\n") {
|
|
||||||
global::isN437 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n306\n") {
|
|
||||||
global::isN306 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n249\n") {
|
|
||||||
global::isN249 = true;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "kt\n") {
|
|
||||||
global::isKT = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QScreen *screen = qApp->primaryScreen();
|
const QScreen *screen = qApp->primaryScreen();
|
||||||
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
w.setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
|
||||||
|
|
218
src/platform/device.cpp
Normal file
218
src/platform/device.cpp
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
|
#include "device_desktop.h"
|
||||||
|
#include "device_kindle_touch.h"
|
||||||
|
#include "device_kobo_aura_edition2.h"
|
||||||
|
#include "device_kobo_clarahd.h"
|
||||||
|
#include "device_kobo_glo.h"
|
||||||
|
#include "device_kobo_glohd.h"
|
||||||
|
#include "device_kobo_libra.h"
|
||||||
|
#include "device_kobo_mini.h"
|
||||||
|
#include "device_kobo_nia.h"
|
||||||
|
#include "device_kobo_touch.h"
|
||||||
|
|
||||||
|
|
||||||
|
Device* Device::instance = nullptr;
|
||||||
|
|
||||||
|
Device::Device()
|
||||||
|
{
|
||||||
|
powerSupplyPath = getPowerSupplyPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
Device* Device::getSingleton() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Device::setup(QString &platformName){
|
||||||
|
QString name = platformName.trimmed();
|
||||||
|
Device* temp;
|
||||||
|
|
||||||
|
#define SETUP_DEVICE(x) { \
|
||||||
|
temp = new x(); \
|
||||||
|
if(temp->getID() == name) { \
|
||||||
|
Device::instance = temp;\
|
||||||
|
log("Setting up Device "+Device::instance->getID()+".", "Device::setup"); \
|
||||||
|
return; \
|
||||||
|
} else { \
|
||||||
|
delete temp; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
SETUP_DEVICE(DeviceKindleTouch)
|
||||||
|
|
||||||
|
SETUP_DEVICE(DeviceKoboAuraEdition2)
|
||||||
|
SETUP_DEVICE(DeviceKoboClaraHD)
|
||||||
|
SETUP_DEVICE(DeviceKoboGlo)
|
||||||
|
SETUP_DEVICE(DeviceKoboGloHD)
|
||||||
|
SETUP_DEVICE(DeviceKoboLibra)
|
||||||
|
SETUP_DEVICE(DeviceKoboMini)
|
||||||
|
SETUP_DEVICE(DeviceKoboNia)
|
||||||
|
SETUP_DEVICE(DeviceKoboTouch)
|
||||||
|
|
||||||
|
// Fallback if none of the devices above worked
|
||||||
|
Device::instance = new DeviceDesktop();
|
||||||
|
|
||||||
|
log("Setting up Device "+Device::instance->getID()+".", "Device::setup");
|
||||||
|
fprintf(stderr, "Device has fallen back to desktop.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::writeFile(QString path, QString content) {
|
||||||
|
QFile file(path);
|
||||||
|
if(file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << content;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, ("Failed to write to file: "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Device::readFile(QString path) {
|
||||||
|
QFile file(path);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
QTextStream in (&file);
|
||||||
|
QString content = in.readAll();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return content.trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
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/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QString Device::getStyleSheetPath() {
|
||||||
|
return "/mnt/onboard/.adds/inkbox/";
|
||||||
|
}
|
||||||
|
|
||||||
|
Device::SysInfo Device::getSystemInfo() {
|
||||||
|
// get UID
|
||||||
|
QString prog ("dd");
|
||||||
|
QStringList args;
|
||||||
|
args << "if=/dev/mmcblk0" << "bs=512" << "skip=1" << "count=1" << "status=none";
|
||||||
|
QProcess *proc = new QProcess();
|
||||||
|
proc->start(prog, args);
|
||||||
|
proc->waitForFinished();
|
||||||
|
|
||||||
|
QString deviceUID = proc->readAllStandardOutput();
|
||||||
|
deviceUID = deviceUID.left(256);
|
||||||
|
proc->deleteLater();
|
||||||
|
|
||||||
|
// get Kernel Version
|
||||||
|
prog = "uname";
|
||||||
|
args = QStringList();
|
||||||
|
args << "-r";
|
||||||
|
proc = new QProcess();
|
||||||
|
proc->start(prog, args);
|
||||||
|
proc->waitForFinished();
|
||||||
|
|
||||||
|
QString kernelVersion = proc->readAllStandardOutput();
|
||||||
|
kernelVersion = kernelVersion.trimmed();
|
||||||
|
|
||||||
|
proc->deleteLater();
|
||||||
|
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile("/external_root/run/initrd-fifo", "get_kernel_build_id\n");
|
||||||
|
QThread::msleep(100);
|
||||||
|
writeFile("/external_root/run/initrd-fifo", "get_kernel_commit\n");
|
||||||
|
QThread::msleep(100);
|
||||||
|
|
||||||
|
QString kernelBuildID = readFile("/external_root/run/kernel_build_id").trimmed();
|
||||||
|
|
||||||
|
QString kernelCommit = readFile("/external_root/run/kernel_commit").trimmed();
|
||||||
|
|
||||||
|
|
||||||
|
SysInfo info = {
|
||||||
|
.uid= deviceUID,
|
||||||
|
.kernelVersion= kernelVersion,
|
||||||
|
.kernelBuild= kernelBuildID,
|
||||||
|
.kernelCommit= kernelCommit,
|
||||||
|
|
||||||
|
.inkOSVersion= readFile("/external_root/opt/isa/version"),
|
||||||
|
.inkGitVersion = GIT_VERSION,
|
||||||
|
|
||||||
|
.ipAddress = getConnectionInformation()
|
||||||
|
};
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Device::supportsWifi() {
|
||||||
|
return checkconfig("/run/wifi_able");
|
||||||
|
}
|
||||||
|
|
||||||
|
int Device::getBatteryLevel() {
|
||||||
|
int value = 100;
|
||||||
|
if(QFile::exists("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity")) {
|
||||||
|
value = readFile("/sys/devices/platform/pmic_battery.1/power_supply/mc13892_bat/capacity").toInt();
|
||||||
|
} else if(QFile::exists(powerSupplyPath + "/capacity")) {
|
||||||
|
value = readFile(powerSupplyPath + "/capacity").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Device::getBrightness() {
|
||||||
|
if(QFile::exists("/var/run/brightness")) {
|
||||||
|
return readFile("/var/run/brightness").toInt();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::setBrightness(int value) {
|
||||||
|
if(QFile::exists("/var/run/brightness")) {
|
||||||
|
std::ofstream fhandler;
|
||||||
|
fhandler.open("/var/run/brightness");
|
||||||
|
fhandler << value;
|
||||||
|
fhandler.close();
|
||||||
|
} else if(QFile::exists("/var/run/brightness_write")) {
|
||||||
|
// this is for N249 devices. Overwrite this virtual method for that platform instead
|
||||||
|
std::ofstream fhandler;
|
||||||
|
fhandler.open("/var/run/brightness_write");
|
||||||
|
fhandler << value;
|
||||||
|
fhandler.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::supportsNightmode() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Device::getBaseDPI() {
|
||||||
|
return 125;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::isUSBPluggedIn() {
|
||||||
|
// Thanks to https://github.com/koreader/KoboUSBMS/blob/2efdf9d920c68752b2933f21c664dc1afb28fc2e/usbms.c#L148-L158
|
||||||
|
int ntxfd;
|
||||||
|
if((ntxfd = open("/dev/ntx_io", O_RDWR)) == -1) {
|
||||||
|
fprintf(stderr, "Error opening ntx_io device\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
unsigned long ptr = 0U;
|
||||||
|
ioctl(ntxfd, 108, &ptr);
|
||||||
|
close(ntxfd);
|
||||||
|
return !!ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Device::loadUSBMassStorageModule() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Device::getUSBMassStorageModule() {
|
||||||
|
return "/external_root/lib/modules/g_mass_storage.ko";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Device::getNetworkInterfaceName() {
|
||||||
|
return "wlan0";
|
||||||
|
}
|
130
src/platform/device.h
Normal file
130
src/platform/device.h
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
#ifndef PLATFORM_H
|
||||||
|
#define PLATFORM_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Device
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static Device* instance;
|
||||||
|
QString powerSupplyPath;
|
||||||
|
|
||||||
|
QString getPowerSupplyPath();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Device();
|
||||||
|
|
||||||
|
void writeFile(QString path, QString content);
|
||||||
|
QString readFile(QString path);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~Device() = default;
|
||||||
|
|
||||||
|
static void setup(QString& platformName);
|
||||||
|
/*
|
||||||
|
|
||||||
|
if(global::deviceID == "n705\n") {
|
||||||
|
global::isN705 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n905\n") {
|
||||||
|
global::isN905C = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n613\n") {
|
||||||
|
global::isN613 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n873\n") {
|
||||||
|
global::isN873 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n236\n") {
|
||||||
|
global::isN236 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n437\n") {
|
||||||
|
global::isN437 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "n306\n") {
|
||||||
|
global::isN306 = true;
|
||||||
|
}
|
||||||
|
^else if(global::deviceID == "n249\n") {
|
||||||
|
global::isN249 = true;
|
||||||
|
}
|
||||||
|
else if(global::deviceID == "kt\n") {
|
||||||
|
global::isKT = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static Device* getSingleton();
|
||||||
|
|
||||||
|
virtual QString getID() = 0;
|
||||||
|
|
||||||
|
struct SysInfo {
|
||||||
|
QString uid;
|
||||||
|
|
||||||
|
QString kernelVersion;
|
||||||
|
QString kernelBuild;
|
||||||
|
QString kernelCommit;
|
||||||
|
|
||||||
|
QString inkOSVersion;
|
||||||
|
QString inkGitVersion;
|
||||||
|
|
||||||
|
QString ipAddress;
|
||||||
|
};
|
||||||
|
virtual SysInfo getSystemInfo();
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() = 0;
|
||||||
|
|
||||||
|
virtual bool supportsWifi() = 0;
|
||||||
|
|
||||||
|
// BATTERY stuff
|
||||||
|
|
||||||
|
virtual bool hasBattery() = 0;
|
||||||
|
virtual int getBatteryLevel();
|
||||||
|
// Generic Battery Utility functions
|
||||||
|
bool isBatteryCritical() {
|
||||||
|
return getBatteryLevel() < 5;
|
||||||
|
}
|
||||||
|
bool isBatteryLow() {
|
||||||
|
return getBatteryLevel() < 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only true for isN249 and isN873
|
||||||
|
virtual bool supportsWarmLight() = 0;
|
||||||
|
// 100 for N249 and 10 for N873
|
||||||
|
virtual int getMaxWarmLightValue() = 0;
|
||||||
|
virtual int getWarmth() = 0;
|
||||||
|
virtual void setWarmth(int value) = 0;
|
||||||
|
|
||||||
|
virtual bool supportsBrightness()=0;
|
||||||
|
|
||||||
|
virtual int getBrightness();
|
||||||
|
virtual void setBrightness(int value);
|
||||||
|
|
||||||
|
virtual bool supportsNightmode();
|
||||||
|
|
||||||
|
virtual int getBaseDPI();
|
||||||
|
|
||||||
|
enum ScreenSize {
|
||||||
|
SMALL, // Kobo Mini (705)
|
||||||
|
MEDIUM,
|
||||||
|
LARGE, // Kobo Glo HD (437), 249
|
||||||
|
VERY_LARGE // Kobo Libra (873)
|
||||||
|
};
|
||||||
|
virtual ScreenSize getScreenSize() = 0;
|
||||||
|
|
||||||
|
// USB Mass Storage Stuff
|
||||||
|
virtual bool isUSBPluggedIn();
|
||||||
|
virtual void loadUSBMassStorageModule();
|
||||||
|
virtual QString getUSBMassStorageModule();
|
||||||
|
|
||||||
|
// NETWORK
|
||||||
|
virtual QString getNetworkInterfaceName();
|
||||||
|
|
||||||
|
// PATHS
|
||||||
|
virtual const QString getStyleSheetPath();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLATFORM_H
|
6
src/platform/device_desktop.cpp
Normal file
6
src/platform/device_desktop.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "device_desktop.h"
|
||||||
|
|
||||||
|
DeviceDesktop::DeviceDesktop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
53
src/platform/device_desktop.h
Normal file
53
src/platform/device_desktop.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef DEVICEDESKTOP_H
|
||||||
|
#define DEVICEDESKTOP_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceDesktop : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceDesktop();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "desktop";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 125;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::VERY_LARGE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEDESKTOP_H
|
28
src/platform/device_kindle_touch.cpp
Normal file
28
src/platform/device_kindle_touch.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include "device_kindle_touch.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceKindleTouch::isUSBPluggedIn() {
|
||||||
|
return readFile("/sys/devices/system/yoshi_battery/yoshi_battery0/battery_status").toInt() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKindleTouch::loadUSBMassStorageModule() {
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/arcotg_udc.ko");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DeviceKindleTouch::getUSBMassStorageModule() {
|
||||||
|
return "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/g_file_storage.ko";
|
||||||
|
}
|
61
src/platform/device_kindle_touch.h
Normal file
61
src/platform/device_kindle_touch.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#ifndef DEVICEKINDLETOUCH_H
|
||||||
|
#define DEVICEKINDLETOUCH_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKindleTouch : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKindleTouch();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "kt";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual int getBatteryLevel() override;
|
||||||
|
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 125;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USB
|
||||||
|
virtual bool isUSBPluggedIn() override;
|
||||||
|
virtual void loadUSBMassStorageModule() override;
|
||||||
|
virtual QString getUSBMassStorageModule() override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKINDLETOUCH_H
|
6
src/platform/device_kobo_aura_edition2.cpp
Normal file
6
src/platform/device_kobo_aura_edition2.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "device_kobo_aura_edition2.h"
|
||||||
|
|
||||||
|
DeviceKoboAuraEdition2::DeviceKoboAuraEdition2()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
53
src/platform/device_kobo_aura_edition2.h
Normal file
53
src/platform/device_kobo_aura_edition2.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef KOBOAURAEDITION2_H
|
||||||
|
#define KOBOAURAEDITION2_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboAuraEdition2 : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboAuraEdition2();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n236";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 175;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::MEDIUM;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KOBOAURAEDITION2_H
|
43
src/platform/device_kobo_clarahd.cpp
Normal file
43
src/platform/device_kobo_clarahd.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#include "device_kobo_clarahd.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
DeviceKoboClaraHD::DeviceKoboClaraHD()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeviceKoboClaraHD::getWarmth() {
|
||||||
|
QString sysfsWarmthPath = "/sys/class/backlight/backlight_warm/actual_brightness";
|
||||||
|
int warmthValue;
|
||||||
|
|
||||||
|
QString warmthConfig = readFile(sysfsWarmthPath);
|
||||||
|
warmthValue = warmthConfig.toInt();
|
||||||
|
return warmthValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboClaraHD::setWarmth(int value) {
|
||||||
|
QString sysfsWarmthPath = "/sys/class/backlight/backlight_warm/brightness";
|
||||||
|
QString warmthValueStr =QString::number(value);
|
||||||
|
|
||||||
|
writeFile(sysfsWarmthPath, warmthValueStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboClaraHD::setBrightness(int value) {
|
||||||
|
if(QFile::exists("/var/run/brightness_write")) {
|
||||||
|
writeFile("/var/run/brightness_write", QString::number(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//USB
|
||||||
|
bool DeviceKoboClaraHD::isUSBPluggedIn() {
|
||||||
|
return (readFile("/sys/class/power_supply/rn5t618-battery/status") != "Discharging\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboClaraHD::loadUSBMassStorageModule() {
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/fs/configfs/configfs.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/libcomposite.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
||||||
|
}
|
63
src/platform/device_kobo_clarahd.h
Normal file
63
src/platform/device_kobo_clarahd.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#ifndef DEVICEKOBOCLARAHD_H
|
||||||
|
#define DEVICEKOBOCLARAHD_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboClaraHD : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboClaraHD();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n249";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 100;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override;
|
||||||
|
virtual void setWarmth(int value) override;
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
virtual void setBrightness(int value) override;
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 225;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//USB
|
||||||
|
virtual bool isUSBPluggedIn() override;
|
||||||
|
virtual void loadUSBMassStorageModule() override;
|
||||||
|
|
||||||
|
// NETWORK
|
||||||
|
virtual QString getNetworkInterfaceName() override {
|
||||||
|
return "etho0";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOCLARAHD_H
|
34
src/platform/device_kobo_glo.cpp
Normal file
34
src/platform/device_kobo_glo.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include "device_kobo_glo.h"
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
DeviceKoboGlo::DeviceKoboGlo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeviceKoboGlo::getBrightness() {
|
||||||
|
return readFile(".config/03-brightness/config").toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboGlo::setBrightness(int value) {
|
||||||
|
int fd;
|
||||||
|
if((fd = open("/dev/ntx_io", O_RDWR)) == -1) {
|
||||||
|
fprintf(stderr, "Error opening ntx_io device while setting brightness.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ioctl(fd, 241, value);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
// also store it somewhere so we can load it when we need it for getBrightness
|
||||||
|
std::ofstream fhandler;
|
||||||
|
fhandler.open(".config/03-brightness/config");
|
||||||
|
fhandler << value;
|
||||||
|
fhandler.close();
|
||||||
|
}
|
56
src/platform/device_kobo_glo.h
Normal file
56
src/platform/device_kobo_glo.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef DEVICEKOBOGLO_H
|
||||||
|
#define DEVICEKOBOGLO_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboGlo : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboGlo();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n613";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
virtual int getBrightness() override;
|
||||||
|
virtual void setBrightness(int value) override;
|
||||||
|
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 175;
|
||||||
|
};
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::MEDIUM;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOGLO_H
|
6
src/platform/device_kobo_glohd.cpp
Normal file
6
src/platform/device_kobo_glohd.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "device_kobo_glohd.h"
|
||||||
|
|
||||||
|
DeviceKoboGloHD::DeviceKoboGloHD()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
58
src/platform/device_kobo_glohd.h
Normal file
58
src/platform/device_kobo_glohd.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef DEVICEKOBOGLOHD_H
|
||||||
|
#define DEVICEKOBOGLOHD_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboGloHD : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboGloHD();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n437";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 225;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//NETWORK
|
||||||
|
virtual QString getNetworkInterfaceName() override {
|
||||||
|
return "eth0";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOGLOHD_H
|
35
src/platform/device_kobo_libra.cpp
Normal file
35
src/platform/device_kobo_libra.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#include "device_kobo_libra.h"
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
DeviceKoboLibra::DeviceKoboLibra()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeviceKoboLibra::getWarmth() {
|
||||||
|
QString sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
||||||
|
int warmthValue;
|
||||||
|
QString warmthConfig = readFile(sysfsWarmthPath);
|
||||||
|
warmthValue = warmthConfig.toInt();
|
||||||
|
warmthValue = 10 - warmthValue;
|
||||||
|
|
||||||
|
return warmthValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboLibra::setWarmth(int value) {
|
||||||
|
QString sysfsWarmthPath;
|
||||||
|
QString warmthValueStr;
|
||||||
|
// Value 0 gives a warmer lighting than value 10
|
||||||
|
value = 10 - value;
|
||||||
|
warmthValueStr = QString::number(value);
|
||||||
|
sysfsWarmthPath = "/sys/class/backlight/lm3630a_led/color";
|
||||||
|
|
||||||
|
writeFile(sysfsWarmthPath, warmthValueStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceKoboLibra::loadUSBMassStorageModule() {
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/fs/configfs/configfs.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/libcomposite.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
||||||
|
|
||||||
|
}
|
56
src/platform/device_kobo_libra.h
Normal file
56
src/platform/device_kobo_libra.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef DEVICEKOBOLIBRA_H
|
||||||
|
#define DEVICEKOBOLIBRA_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboLibra : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboLibra();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n873";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 10;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override;
|
||||||
|
virtual void setWarmth(int value) override;
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 250;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::VERY_LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//USB
|
||||||
|
virtual void loadUSBMassStorageModule() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOLIBRA_H
|
13
src/platform/device_kobo_mini.cpp
Normal file
13
src/platform/device_kobo_mini.cpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include "device_kobo_mini.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
|
|
||||||
|
DeviceKoboMini::DeviceKoboMini()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
50
src/platform/device_kobo_mini.h
Normal file
50
src/platform/device_kobo_mini.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef DEVICEKOBOMINI_H
|
||||||
|
#define DEVICEKOBOMINI_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboMini : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboMini();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n705";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::SMALL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOMINI_H
|
16
src/platform/device_kobo_nia.cpp
Normal file
16
src/platform/device_kobo_nia.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "device_kobo_nia.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
DeviceKoboNia::DeviceKoboNia()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceKoboNia::loadUSBMassStorageModule() {
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/fs/configfs/configfs.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/libcomposite.ko");
|
||||||
|
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
||||||
|
|
||||||
|
}
|
56
src/platform/device_kobo_nia.h
Normal file
56
src/platform/device_kobo_nia.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef DEVICEKOBONIA_H
|
||||||
|
#define DEVICEKOBONIA_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboNia : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboNia();
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n306";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual int getBaseDPI() override {
|
||||||
|
return 175;
|
||||||
|
}
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
//USB
|
||||||
|
virtual void loadUSBMassStorageModule() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBONIA_H
|
6
src/platform/device_kobo_touch.cpp
Normal file
6
src/platform/device_kobo_touch.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "device_kobo_touch.h"
|
||||||
|
|
||||||
|
DeviceKoboTouch::DeviceKoboTouch()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
53
src/platform/device_kobo_touch.h
Normal file
53
src/platform/device_kobo_touch.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef DEVICEKOBOTOUCH_H
|
||||||
|
#define DEVICEKOBOTOUCH_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
class DeviceKoboTouch : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceKoboTouch();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual QString getID() override {
|
||||||
|
return "n905";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool hasNavButtons() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool supportsWifi() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BATTERY
|
||||||
|
virtual bool hasBattery() override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
// WARM LIGHT
|
||||||
|
virtual bool supportsWarmLight() override {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
virtual int getMaxWarmLightValue() override {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
virtual int getWarmth() override {return 0;};
|
||||||
|
virtual void setWarmth(int value) override {};
|
||||||
|
|
||||||
|
// BRIGHTNESS
|
||||||
|
virtual bool supportsBrightness() override {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SIZE
|
||||||
|
virtual ScreenSize getScreenSize() override {
|
||||||
|
return ScreenSize::MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEKOBOTOUCH_H
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
sleepThread::sleepThread() {}
|
SleepThread::SleepThread() {}
|
||||||
|
|
||||||
void sleepThread::start()
|
void SleepThread::start()
|
||||||
{
|
{
|
||||||
log("Sleep pipe thread active", className);
|
log("Sleep pipe thread active", className);
|
||||||
QDir pipeDirPath = QDir("/dev/ipd");
|
QDir pipeDirPath = QDir("/dev/ipd");
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class sleepThread : public QObject {
|
class SleepThread : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
sleepThread();
|
SleepThread();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
#include "quit.h"
|
|
||||||
#include "ui_quit.h"
|
|
||||||
#include "functions.h"
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <linux/input.h>
|
|
||||||
|
|
||||||
quit::quit(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::quit)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->backBtn->setFont(QFont("u001"));
|
|
||||||
|
|
||||||
ui->pushButton->setProperty("type", "borderless");
|
|
||||||
ui->pushButton_2->setProperty("type", "borderless");
|
|
||||||
ui->pushButton_3->setProperty("type", "borderless");
|
|
||||||
ui->pushButton_4->setProperty("type", "borderless");
|
|
||||||
ui->backBtn->setProperty("type", "borderless");
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
// Getting the screen's size
|
|
||||||
float sW = QGuiApplication::screens()[0]->size().width();
|
|
||||||
float sH = QGuiApplication::screens()[0]->size().height();
|
|
||||||
// Defining what the "Quit" icon size will be
|
|
||||||
float stdIconWidth = sW / 1.25;
|
|
||||||
float stdIconHeight = sH / 1.25;
|
|
||||||
|
|
||||||
QPixmap pixmap(":/resources/exit.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->label->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
|
||||||
ui->pushButton_3->setText("Deep suspend");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
quit::~quit()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
// Prevent strange "appearing from nowhere" low battery or critical battery alerts due to sysfs unmount
|
|
||||||
global::battery::showCriticalBatteryAlert = false;
|
|
||||||
global::battery::showLowBatteryDialog = false;
|
|
||||||
|
|
||||||
// GUI apps
|
|
||||||
updateUserAppsMainJsonFile();
|
|
||||||
|
|
||||||
poweroff(true);
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit::on_pushButton_2_clicked()
|
|
||||||
{
|
|
||||||
global::battery::showCriticalBatteryAlert = false;
|
|
||||||
global::battery::showLowBatteryDialog = false;
|
|
||||||
|
|
||||||
// GUI apps
|
|
||||||
updateUserAppsMainJsonFile();
|
|
||||||
|
|
||||||
reboot(true);
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit::on_pushButton_4_clicked()
|
|
||||||
{
|
|
||||||
log("Restarting InkBox", className);
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit::on_backBtn_clicked()
|
|
||||||
{
|
|
||||||
quit::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void quit::on_pushButton_3_clicked()
|
|
||||||
{
|
|
||||||
log("Suspending", className);
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
|
||||||
writeFile("/dev/ipd/sleepCall", "deepSleep");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
writeFile("/dev/ipd/sleepCall", "sleep");
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,136 +0,0 @@
|
||||||
#include "koboxsettings.h"
|
|
||||||
#include "ui_koboxsettings.h"
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QScreen>
|
|
||||||
|
|
||||||
koboxSettings::koboxSettings(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::koboxSettings)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
koboxSettings::setFont(QFont("u001"));
|
|
||||||
ui->okBtn->setFont(QFont("Inter"));
|
|
||||||
|
|
||||||
// UI tweaks
|
|
||||||
ui->okBtn->setProperty("type", "borderless");
|
|
||||||
ui->pushButton->setProperty("type", "borderless");
|
|
||||||
ui->resetKoboxBtn->setProperty("type", "borderless");
|
|
||||||
ui->pushButton->setStyleSheet("font-weight: bold");
|
|
||||||
ui->resetKoboxBtn->setStyleSheet("font-weight: bold");
|
|
||||||
ui->okBtn->setStyleSheet("font-weight: bold");
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
if(checkconfig("/external_root/boot/flags/X11_START") == true) {
|
|
||||||
ui->koboxStatusLabel->setText("KoBox is <b>enabled</b>");
|
|
||||||
not_user_change = true;
|
|
||||||
ui->checkBox->click();
|
|
||||||
ui->runtimeSettingsWidget->setVisible(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
|
|
||||||
ui->runtimeSettingsWidget->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DPI setting
|
|
||||||
QString dpiSetting;
|
|
||||||
QString dpiSettingStr = readFile(".config/00-kobox/dpiSetting");
|
|
||||||
if(dpiSettingStr.isEmpty()) {
|
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
dpiSetting = "125";
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
|
||||||
dpiSetting = "175";
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n437\n" or global::deviceID == "n249\n") {
|
|
||||||
dpiSetting = "225";
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
dpiSetting = "250";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dpiSetting = "125";
|
|
||||||
}
|
|
||||||
writeFile(".config/00-kobox/dpiSetting", dpiSetting);
|
|
||||||
}
|
|
||||||
|
|
||||||
readFile(".config/00-kobox/dpiSetting");
|
|
||||||
int dpi_setting = dpiSettingStr.toInt();
|
|
||||||
ui->spinBox->setValue(dpi_setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
koboxSettings::~koboxSettings()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::on_okBtn_clicked()
|
|
||||||
{
|
|
||||||
koboxSettings::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::on_checkBox_toggled(bool checked)
|
|
||||||
{
|
|
||||||
if(checked == true) {
|
|
||||||
if(not_user_change != true) {
|
|
||||||
log("Enabling KoBox subsystem", className);
|
|
||||||
writeFile("/external_root/boot/flags/X11_START", "true\n");
|
|
||||||
openSettingsRebootDialog();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
not_user_change = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log("Disabling KoBox subsystem", className);
|
|
||||||
writeFile("/external_root/boot/flags/X11_START", "false\n");
|
|
||||||
openSettingsRebootDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::openSettingsRebootDialog() {
|
|
||||||
log("Showing reboot dialog", className);
|
|
||||||
global::settings::settingsRebootDialog = true;
|
|
||||||
global::kobox::koboxSettingsRebootDialog = true;
|
|
||||||
generalDialogWindow = new generalDialog(this);
|
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
}
|
|
||||||
void koboxSettings::openResetKoboxDialog() {
|
|
||||||
log("Showing KoBox reset dialog", className);
|
|
||||||
global::kobox::resetKoboxDialog = true;
|
|
||||||
generalDialogWindow = new generalDialog(this);
|
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::on_spinBox_valueChanged(int arg1)
|
|
||||||
{
|
|
||||||
QString number = QString::number(arg1);
|
|
||||||
writeFile(".config/00-kobox/dpiSetting", number);
|
|
||||||
log("X11 DPI set to " + number, className);
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
// Export Extensions disk image over USB with g_mass_storage/g_file_storage
|
|
||||||
global::usbms::usbmsDialog = false;
|
|
||||||
global::usbms::launchUsbms = true;
|
|
||||||
global::usbms::koboxExportExtensions = true;
|
|
||||||
|
|
||||||
log("Exporting KoBox extensions onboard storage via USB", className);
|
|
||||||
log("Showing USBMS splash", className);
|
|
||||||
usbmsWindow = new usbmsSplash();
|
|
||||||
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
usbmsWindow->setGeometry(QRect(QPoint(0,0), screen()->geometry ().size()));
|
|
||||||
usbmsWindow->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void koboxSettings::on_resetKoboxBtn_clicked()
|
|
||||||
{
|
|
||||||
openResetKoboxDialog();
|
|
||||||
}
|
|
|
@ -1,434 +0,0 @@
|
||||||
#include "powerdaemonsettings.h"
|
|
||||||
#include "ui_powerdaemonsettings.h"
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::powerDaemonSettings)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
powerDaemonSettings::setFont(QFont("u001"));
|
|
||||||
ui->mainLabel->setFont(QFont("Inter"));
|
|
||||||
|
|
||||||
// Avoid some display issues (label moving because width of text would change with a proportional font)
|
|
||||||
ui->CBSLabel->setFont(QFont("Roboto Mono"));
|
|
||||||
ui->idleSleepLabel->setFont(QFont("Roboto Mono"));
|
|
||||||
|
|
||||||
// Font tweaks
|
|
||||||
ui->label_2->setFont(QFont("Inter"));
|
|
||||||
ui->exitBtn->setFont(QFont("Inter"));
|
|
||||||
|
|
||||||
// UI tweaks
|
|
||||||
ui->exitBtn->setProperty("type", "borderless");
|
|
||||||
ui->expBtn->setProperty("type", "borderless");
|
|
||||||
ui->hWhenChargerSleepBtn->setProperty("type", "borderless");
|
|
||||||
ui->hChargerWakeUpBtn->setProperty("type", "borderless");
|
|
||||||
ui->wifiReconnectBtn->setProperty("type", "borderless");
|
|
||||||
ui->ledUsageBtn->setProperty("type", "borderless");
|
|
||||||
ui->hCustomCaseBtn->setProperty("type", "borderless");
|
|
||||||
ui->deepSleepBtn->setProperty("type", "borderless");
|
|
||||||
|
|
||||||
ui->mainLabel->setStyleSheet("font-weight: bold");
|
|
||||||
ui->CBSLabel->setStyleSheet("font-weight: bold");
|
|
||||||
ui->idleSleepLabel->setStyleSheet("font-weight: bold");
|
|
||||||
ui->exitBtn->setStyleSheet("font-weight: bold");
|
|
||||||
// Experimental features label
|
|
||||||
ui->label_2->setStyleSheet("font-weight: bold");
|
|
||||||
|
|
||||||
// Icons
|
|
||||||
int controlBtnFixedWidth;
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
controlBtnFixedWidth = 50;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
controlBtnFixedWidth = 80;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->CBSDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
|
|
||||||
ui->CBSDecreaseBtn->setFixedWidth(controlBtnFixedWidth);
|
|
||||||
ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
|
|
||||||
ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedWidth);
|
|
||||||
|
|
||||||
|
|
||||||
int idleBtnsFixedWidth;
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
idleBtnsFixedWidth = 80;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idleBtnsFixedWidth = 100;
|
|
||||||
}
|
|
||||||
ui->idleSleepDecreaseBtn->setFixedWidth(idleBtnsFixedWidth);
|
|
||||||
ui->idleSleepIncreaseBtn->setFixedWidth(idleBtnsFixedWidth);
|
|
||||||
ui->idleSleepDecreaseMBtn->setFixedWidth(idleBtnsFixedWidth);
|
|
||||||
ui->idleSleepIncreaseMBtn->setFixedWidth(idleBtnsFixedWidth);
|
|
||||||
|
|
||||||
// Padding
|
|
||||||
ui->CBSDecreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt");
|
|
||||||
ui->CBSIncreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt");
|
|
||||||
ui->idleSleepDecreaseBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
|
||||||
ui->idleSleepIncreaseBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
|
||||||
ui->idleSleepDecreaseMBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
|
||||||
ui->idleSleepIncreaseMBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
// Button tweaks
|
|
||||||
int autoRepeatDelay = 1250;
|
|
||||||
int autoRepeatInterval = 20;
|
|
||||||
|
|
||||||
ui->CBSDecreaseBtn->setAutoRepeat(true);
|
|
||||||
ui->CBSDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->CBSDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
ui->CBSIncreaseBtn->setAutoRepeat(true);
|
|
||||||
ui->CBSIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->CBSIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
ui->idleSleepDecreaseBtn->setAutoRepeat(true);
|
|
||||||
ui->idleSleepDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->idleSleepDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
ui->idleSleepIncreaseBtn->setAutoRepeat(true);
|
|
||||||
ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->idleSleepIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
ui->idleSleepDecreaseMBtn->setAutoRepeat(true);
|
|
||||||
ui->idleSleepDecreaseMBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->idleSleepDecreaseMBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
ui->idleSleepIncreaseMBtn->setAutoRepeat(true);
|
|
||||||
ui->idleSleepIncreaseMBtn->setAutoRepeatDelay(autoRepeatDelay);
|
|
||||||
ui->idleSleepIncreaseMBtn->setAutoRepeatInterval(autoRepeatInterval);
|
|
||||||
|
|
||||||
// Hide items
|
|
||||||
ui->hLabel_3->hide();
|
|
||||||
ui->hCpuFreqComboBox->hide();
|
|
||||||
|
|
||||||
ui->hWhenChargerSleepBtn->hide();
|
|
||||||
ui->hChargerWakeUpBtn->hide();
|
|
||||||
ui->hCustomCaseBtn->hide();
|
|
||||||
|
|
||||||
// Prepare variables from system configuration (20-sleep_daemon)
|
|
||||||
log("Reading variables from power daemon configuration", className);
|
|
||||||
|
|
||||||
// 1 - cinematicBrightnessDelayMs
|
|
||||||
QString cinematicBrightnessMs = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs");
|
|
||||||
|
|
||||||
cinematicBrightnessInt = cinematicBrightnessMs.toInt();
|
|
||||||
convertCinematicInt();
|
|
||||||
|
|
||||||
// 2 - cpuGovernor
|
|
||||||
QString cpuGovernor = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor");
|
|
||||||
|
|
||||||
QStringList cpuGovernorList = QStringList{cpuGovernor};
|
|
||||||
if(cpuGovernorList.contains("interactive") == false) {
|
|
||||||
cpuGovernorList.append("interactive");
|
|
||||||
}
|
|
||||||
if(cpuGovernorList.contains("conservative") == false) {
|
|
||||||
cpuGovernorList.append("conservative");
|
|
||||||
}
|
|
||||||
if(cpuGovernorList.contains("userspace") == false) {
|
|
||||||
cpuGovernorList.append("userspace");
|
|
||||||
}
|
|
||||||
if(cpuGovernorList.contains("powersave") == false) {
|
|
||||||
cpuGovernorList.append("powersave");
|
|
||||||
}
|
|
||||||
if(cpuGovernorList.contains("ondemand") == false) {
|
|
||||||
cpuGovernorList.append("ondemand");
|
|
||||||
}
|
|
||||||
if(cpuGovernorList.contains("performance") == false) {
|
|
||||||
cpuGovernorList.append("performance");
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->hCpuFreqComboBox->addItems(cpuGovernorList);
|
|
||||||
ui->hCpuFreqComboBox->setCurrentIndex(0);
|
|
||||||
|
|
||||||
// 3 - whenChargerSleep
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep") == true) {
|
|
||||||
whenChargerSleepBool = true;
|
|
||||||
ui->hWhenChargerSleepBtn->click();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
whenChargerSleepBool = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4 - chargerWakeUp
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp") == true) {
|
|
||||||
chargerWakeUpBool = true;
|
|
||||||
ui->hChargerWakeUpBtn->click();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chargerWakeUpBool = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5 - wifiReconnect
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect") == true) {
|
|
||||||
ui->wifiReconnectBtn->click();
|
|
||||||
wifiReconnectBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wifiReconnectBool = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6 - ledUsage
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage") == true) {
|
|
||||||
ui->ledUsageBtn->click();
|
|
||||||
ledUsageBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ledUsageBool = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7 - idleSleep
|
|
||||||
QString idleSleepString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/7-idleSleep");
|
|
||||||
idleSleepInt = idleSleepString.replace("\n", "").toInt();
|
|
||||||
convertIdleSleepInt();
|
|
||||||
|
|
||||||
// 8 - customCase
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase") == true) {
|
|
||||||
ui->hCustomCaseBtn->click();
|
|
||||||
customCaseBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
customCaseBool = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 9 - deepSleep
|
|
||||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
|
||||||
ui->deepSleepBtn->click();
|
|
||||||
deepSleepBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
deepSleepBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
powerDaemonSettings::~powerDaemonSettings()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_CBSIncreaseBtn_clicked()
|
|
||||||
{
|
|
||||||
if(cinematicBrightnessInt < 500) {
|
|
||||||
cinematicBrightnessInt = cinematicBrightnessInt + 1;
|
|
||||||
convertCinematicInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_CBSDecreaseBtn_clicked()
|
|
||||||
{
|
|
||||||
if(cinematicBrightnessInt != 0) {
|
|
||||||
cinematicBrightnessInt = cinematicBrightnessInt - 1;
|
|
||||||
convertCinematicInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_exitBtn_clicked()
|
|
||||||
{
|
|
||||||
// Save all to files
|
|
||||||
// 1 - cinematicBrightnessdelayMs
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs", QString::number(cinematicBrightnessInt));
|
|
||||||
// 2 - cpuGovernor
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor", ui->hCpuFreqComboBox->currentText());
|
|
||||||
// 3 - whenChargerSleep
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep", QVariant(whenChargerSleepBool).toString());
|
|
||||||
// 4 - chargerWakeUp
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp", QVariant(chargerWakeUpBool).toString());
|
|
||||||
// 5 - wifiReconnect
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect", QVariant(wifiReconnectBool).toString());
|
|
||||||
// 6 - ledUsage
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage", QVariant(ledUsageBool).toString());
|
|
||||||
// 7 - idleSleep
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/7-idleSleep", QString::number(idleSleepInt));
|
|
||||||
// 8 - customCase
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase", QVariant(customCaseBool).toString());
|
|
||||||
// 9 - deepSleep
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep", QVariant(deepSleepBool).toString());
|
|
||||||
|
|
||||||
// Notify power daemon of configuration update
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/updateConfig", "true");
|
|
||||||
|
|
||||||
powerDaemonSettings::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_expBtn_clicked()
|
|
||||||
{
|
|
||||||
// TODO: Implement additional warning
|
|
||||||
ui->hLabel_3->show();
|
|
||||||
ui->hCpuFreqComboBox->show();
|
|
||||||
|
|
||||||
ui->hWhenChargerSleepBtn->show();
|
|
||||||
ui->hChargerWakeUpBtn->show();
|
|
||||||
ui->hCustomCaseBtn->show();
|
|
||||||
|
|
||||||
ui->expBtn->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_hWhenChargerSleepBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "suspend when charging";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
whenChargerSleepBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
whenChargerSleepBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_hChargerWakeUpBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "ignore charger wake-up events";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
chargerWakeUpBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
chargerWakeUpBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_wifiReconnectBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "Wi-Fi reconnection on wake-up";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
wifiReconnectBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
wifiReconnectBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_ledUsageBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "use LED";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
ledUsageBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
ledUsageBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_idleSleepIncreaseBtn_clicked()
|
|
||||||
{
|
|
||||||
if(idleSleepInt >= 15) {
|
|
||||||
idleSleepInt = idleSleepInt + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idleSleepInt = 15;
|
|
||||||
}
|
|
||||||
convertIdleSleepInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_idleSleepDecreaseBtn_clicked() {
|
|
||||||
if(idleSleepInt >= 15) {
|
|
||||||
idleSleepInt = idleSleepInt - 1;
|
|
||||||
if(idleSleepInt == 14) {
|
|
||||||
idleSleepInt = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idleSleepInt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
convertIdleSleepInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::convertIdleSleepInt()
|
|
||||||
{
|
|
||||||
int copiedIdleSleepInt = idleSleepInt;
|
|
||||||
int minutes = 0;
|
|
||||||
int seconds = 0;
|
|
||||||
if(copiedIdleSleepInt == 0) {
|
|
||||||
ui->idleSleepLabel->setText("Never");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while(copiedIdleSleepInt >= 60) {
|
|
||||||
minutes = minutes + 1;
|
|
||||||
copiedIdleSleepInt = copiedIdleSleepInt - 60;
|
|
||||||
}
|
|
||||||
seconds = copiedIdleSleepInt;
|
|
||||||
|
|
||||||
QString text;
|
|
||||||
if(minutes != 0) {
|
|
||||||
text.append(QString::number(minutes) + "m");
|
|
||||||
}
|
|
||||||
if(seconds != 0) {
|
|
||||||
text.append(" ");
|
|
||||||
text.append(QString::number(seconds) + "s");
|
|
||||||
}
|
|
||||||
ui->idleSleepLabel->setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_hCustomCaseBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "custom case";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
customCaseBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
customCaseBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_deepSleepBtn_clicked(bool checked)
|
|
||||||
{
|
|
||||||
QString settingString = "deep sleep";
|
|
||||||
if(checked == true) {
|
|
||||||
logEnabled(settingString, className);
|
|
||||||
deepSleepBool = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logDisabled(settingString, className);
|
|
||||||
deepSleepBool = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::convertCinematicInt() {
|
|
||||||
QString text = QString::number(cinematicBrightnessInt);
|
|
||||||
// To avoid moving other widgets when the value changes
|
|
||||||
text.append(" ms");
|
|
||||||
ui->CBSLabel->setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_idleSleepIncreaseMBtn_clicked()
|
|
||||||
{
|
|
||||||
if(idleSleepInt >= 15) {
|
|
||||||
idleSleepInt = idleSleepInt + 60;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idleSleepInt = 60;
|
|
||||||
}
|
|
||||||
convertIdleSleepInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
void powerDaemonSettings::on_idleSleepDecreaseMBtn_clicked()
|
|
||||||
{
|
|
||||||
if(idleSleepInt >= 60) {
|
|
||||||
idleSleepInt = idleSleepInt - 60;
|
|
||||||
if(idleSleepInt < 14) {
|
|
||||||
idleSleepInt = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idleSleepInt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
convertIdleSleepInt();
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,110 +0,0 @@
|
||||||
#include "settingschooser.h"
|
|
||||||
#include "ui_settingschooser.h"
|
|
||||||
#include "functions.h"
|
|
||||||
#include "powerdaemonsettings.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QScreen>
|
|
||||||
|
|
||||||
settingsChooser::settingsChooser(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::settingsChooser)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
// UI tweaks
|
|
||||||
if(checkconfig("/opt/inkbox_kobox_support") == false) {
|
|
||||||
ui->koboxSettingsBtn->hide();
|
|
||||||
ui->line_3->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getting the screen's size
|
|
||||||
sW = QGuiApplication::screens()[0]->size().width();
|
|
||||||
sH = QGuiApplication::screens()[0]->size().height();
|
|
||||||
|
|
||||||
// Defining what the default icon size will be
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
homeIconWidth = sW / 18;
|
|
||||||
homeIconHeight = sW / 18;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
homeIconWidth = sW / 20;
|
|
||||||
homeIconHeight = sW / 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->inkboxSettingsBtn->setProperty("type", "borderless");
|
|
||||||
ui->koboxSettingsBtn->setProperty("type", "borderless");
|
|
||||||
ui->powerSettingsBtn->setProperty("type", "borderless");
|
|
||||||
|
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
ui->inkboxSettingsBtn->setStyleSheet("padding: 20px; Text-align: left");
|
|
||||||
ui->koboxSettingsBtn->setStyleSheet("padding: 20px; Text-align: left");
|
|
||||||
ui->powerSettingsBtn->setStyleSheet("padding: 20px; Text-align: left");
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
|
||||||
ui->inkboxSettingsBtn->setStyleSheet("padding: 25px; Text-align: left");
|
|
||||||
ui->koboxSettingsBtn->setStyleSheet("padding:25px; Text-align: left");
|
|
||||||
ui->powerSettingsBtn->setStyleSheet("padding:25px; Text-align: left");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->inkboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
|
||||||
ui->koboxSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
|
||||||
ui->powerSettingsBtn->setStyleSheet("padding: 40px; Text-align: left");
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->inkboxSettingsBtn->setText("\t\t\tInkBox settings");
|
|
||||||
ui->koboxSettingsBtn->setText("\t\t\tKoBox settings");
|
|
||||||
ui->powerSettingsBtn->setText("\t\t\tPower settings");
|
|
||||||
|
|
||||||
ui->inkboxSettingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
|
||||||
ui->inkboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
|
||||||
ui->koboxSettingsBtn->setIcon(QIcon(":/resources/X11.png"));
|
|
||||||
ui->koboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
|
||||||
ui->powerSettingsBtn->setIcon(QIcon(":/resources/power.png"));
|
|
||||||
ui->powerSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
|
||||||
}
|
|
||||||
|
|
||||||
settingsChooser::~settingsChooser()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void settingsChooser::on_inkboxSettingsBtn_clicked()
|
|
||||||
{
|
|
||||||
log("Launching InkBox Settings", className);
|
|
||||||
settingsWindow = new settings();
|
|
||||||
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
connect(settingsWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
|
||||||
connect(settingsWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToastNative()));
|
|
||||||
settingsWindow->showFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void settingsChooser::on_koboxSettingsBtn_clicked()
|
|
||||||
{
|
|
||||||
log("Launching KoBox Settings", className);
|
|
||||||
koboxSettingsWindow = new koboxSettings();
|
|
||||||
koboxSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
koboxSettingsWindow->showFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void settingsChooser::on_powerSettingsBtn_clicked()
|
|
||||||
{
|
|
||||||
log("Launching Power Daemon Settings", className);
|
|
||||||
powerDaemonSettings * powerSettingsWindow = new powerDaemonSettings();
|
|
||||||
powerSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
powerSettingsWindow->showFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void settingsChooser::showToastNative(QString messageToDisplay) {
|
|
||||||
emit showToast(messageToDisplay);
|
|
||||||
}
|
|
||||||
|
|
||||||
void settingsChooser::closeIndefiniteToastNative() {
|
|
||||||
emit closeIndefiniteToast();
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
#include "alert.h"
|
|
||||||
#include "ui_alert.h"
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
alert::alert(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::alert)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->messageLabel->setFont(QFont("u001"));
|
|
||||||
|
|
||||||
// Getting the screen's size
|
|
||||||
float sW = QGuiApplication::screens()[0]->size().width();
|
|
||||||
float sH = QGuiApplication::screens()[0]->size().height();
|
|
||||||
// Defining what the "Alert" icon size will be
|
|
||||||
float stdIconWidth = sW / 1.7;
|
|
||||||
float stdIconHeight = sH / 1.7;
|
|
||||||
|
|
||||||
// General stylesheet
|
|
||||||
QFile stylesheetFile(":/resources/eink-dark.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
// Default icon in case none of the conditions below are met
|
|
||||||
QPixmap pixmap(":/resources/alert.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
// Checking if the update's signature is untrusted. The signature error will always take precedence over the downgrade one (c.f. update.sh script)
|
|
||||||
if(checkconfig("/external_root/boot/flags/ALERT_SIGN") == true) {
|
|
||||||
QPixmap pixmap(":/resources/alert.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
signatureError = true;
|
|
||||||
log("Displaying signature error alert splash", className);
|
|
||||||
ui->securityLabel->setText("Failed to update InkBox.");
|
|
||||||
ui->messageLabel->setText("The digital signature of the update is untrusted.\nFor security reasons, it cannot be installed.");
|
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
if(checkconfig("/external_root/boot/flags/ALERT_DOWNGRADE") == true) {
|
|
||||||
QPixmap pixmap(":/resources/alert.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
log("Displaying downgrade error alert splash", className);
|
|
||||||
downgradeError = true;
|
|
||||||
ui->securityLabel->setText("Failed to update InkBox.");
|
|
||||||
ui->messageLabel->setText("An error occured during the update process.\nThe update package's version is lower than the actual installed version.");
|
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
if(global::encfs::lockdown == true) {
|
|
||||||
ui->stackedWidget->setVisible(false);
|
|
||||||
ui->stackedWidget->deleteLater();
|
|
||||||
QPixmap pixmap(":/resources/alert.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
ui->warningLabel->setText("Fatal error");
|
|
||||||
ui->securityLabel->setText("Device lockdown");
|
|
||||||
log(global::encfs::lockdownMessage, className);
|
|
||||||
QString message = "Due to multiple incorrect passphrase attempts, this device is locked down until\n" + global::encfs::unlockTime + "\nand won't boot.";
|
|
||||||
ui->messageLabel->setText(message);
|
|
||||||
poweroff(false);
|
|
||||||
QTimer::singleShot(1000, this, SLOT(quit()));
|
|
||||||
}
|
|
||||||
if(global::battery::showCriticalBatteryAlert == true) {
|
|
||||||
global::battery::showCriticalBatteryAlert = false;
|
|
||||||
ui->stackedWidget->setVisible(false);
|
|
||||||
ui->stackedWidget->deleteLater();
|
|
||||||
|
|
||||||
QPixmap pixmap(":/resources/battery_alert.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->alertIconLabel->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
log("Displaying critical battery alert splash", className);
|
|
||||||
criticalBattery = true;
|
|
||||||
ui->warningLabel->setText("Please charge your eReader.");
|
|
||||||
ui->securityLabel->setText("The battery's charge level is critical.");
|
|
||||||
ui->messageLabel->setText("To prevent damage, your device has been turned off.\nPlease consider charging it.");
|
|
||||||
// The Mini (N705) has a higher DPI and otherwise the text doesn't fit
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 14pt }");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt }");
|
|
||||||
}
|
|
||||||
poweroff(false);
|
|
||||||
QTimer::singleShot(1000, this, SLOT(quit()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 10pt }");
|
|
||||||
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt }");
|
|
||||||
ui->continueBtn->setProperty("type", "borderless");
|
|
||||||
ui->resetBtn->setProperty("type", "borderless");
|
|
||||||
ui->continueBtn->setStyleSheet("padding: 20px");
|
|
||||||
ui->resetBtn->setStyleSheet("padding: 20px");
|
|
||||||
ui->continue2Btn->setProperty("type", "borderless");
|
|
||||||
ui->continue2Btn->setStyleSheet("padding: 20px");
|
|
||||||
}
|
|
||||||
|
|
||||||
alert::~alert()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert::on_continueBtn_clicked()
|
|
||||||
{
|
|
||||||
// We continue anyway and re-set the ALERT flag
|
|
||||||
writeFile("/external_root/boot/flags/ALERT", "false\n");
|
|
||||||
writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n");
|
|
||||||
updateReset();
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert::on_resetBtn_clicked()
|
|
||||||
{
|
|
||||||
// We set the DO_FACTORY_RESET flag and we restart the device
|
|
||||||
log("Factory reset requested; setting required flags", className);
|
|
||||||
writeFile("/external_root/boot/flags/DO_FACTORY_RESET", "true\n");
|
|
||||||
writeFile("/external_root/boot/flags/DIAGS_BOOT", "true\n");
|
|
||||||
QString reboot_prog ("/sbin/reboot");
|
|
||||||
QStringList reboot_args;
|
|
||||||
reboot_args << "no_splash";
|
|
||||||
QProcess *reboot_proc = new QProcess();
|
|
||||||
reboot_proc->start(reboot_prog, reboot_args);
|
|
||||||
reboot_proc->waitForFinished();
|
|
||||||
reboot_proc->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert::on_continue2Btn_clicked()
|
|
||||||
{
|
|
||||||
// We continue anyway and re-set the ALERT flag
|
|
||||||
writeFile("/external_root/boot/flags/ALERT", "false\n");
|
|
||||||
updateReset();
|
|
||||||
|
|
||||||
log("Restarting InkBox", className);
|
|
||||||
if(signatureError == true) {
|
|
||||||
writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n");
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
if(downgradeError == true) {
|
|
||||||
writeFile("/external_root/boot/flags/ALERT_DOWNGRADE", "false\n");
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert::updateReset() {
|
|
||||||
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "false\n");
|
|
||||||
writeFile("/mnt/onboard/onboard/.inkbox/can_update", "false\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void alert::quit() {
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
|
@ -1,287 +0,0 @@
|
||||||
#include "usbmsSplash.h"
|
|
||||||
#include "ui_usbmsSplash.h"
|
|
||||||
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
usbmsSplash::usbmsSplash(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::usbmsSplash)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
usbmsSplash::setFont(QFont("u001"));
|
|
||||||
ui->label->setFont(QFont("Inter"));
|
|
||||||
|
|
||||||
// Getting the screen's size
|
|
||||||
sW = QGuiApplication::screens()[0]->size().width();
|
|
||||||
sH = QGuiApplication::screens()[0]->size().height();
|
|
||||||
|
|
||||||
// Defining what the default icon size will be
|
|
||||||
if(global::kobox::showKoboxSplash == true) {
|
|
||||||
float stdIconWidth = sW / 1.30;
|
|
||||||
float stdIconHeight = sH / 1.30;
|
|
||||||
|
|
||||||
// Stylesheet
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
|
|
||||||
ui->label->setFont(QFont("Inter"));
|
|
||||||
ui->label->setText("Launching KoBox subsystem");
|
|
||||||
ui->label->setStyleSheet("font-size: 14pt; font-weight: bold");
|
|
||||||
ui->label_3->setText("Please wait, this could take a while.");
|
|
||||||
if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
ui->label_3->setStyleSheet("font-size: 11pt");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->label_3->setStyleSheet("font-size: 10pt");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap pixmap(":/resources/kobox-icon.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->label_2->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float stdIconWidth = sW / 1.15;
|
|
||||||
float stdIconHeight = sH / 1.15;
|
|
||||||
|
|
||||||
this->setStyleSheet("background-color:black;");
|
|
||||||
ui->label->setStyleSheet("QLabel { background-color : black; color : white; font-size: 15pt; font-weight: bold }");
|
|
||||||
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 10pt }");
|
|
||||||
|
|
||||||
QPixmap pixmap(":/resources/usbms.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->label_2->setPixmap(scaledPixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(global::usbms::launchUsbms == true) {
|
|
||||||
global::usbms::launchUsbms = false;
|
|
||||||
usbmsLaunch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbmsSplash::usbmsLaunch()
|
|
||||||
{
|
|
||||||
log("Entering USBMS session", className);
|
|
||||||
writeFile("/tmp/in_usbms", "true");
|
|
||||||
QTimer::singleShot(1500, this, SLOT(brightnessDown()));
|
|
||||||
QTimer::singleShot(1500, this, SLOT(warmthDown()));
|
|
||||||
|
|
||||||
if(global::usbms::koboxExportExtensions == true) {
|
|
||||||
writeFile("/opt/ibxd", "kobox_extensions_storage_unmount\n");
|
|
||||||
}
|
|
||||||
if(checkconfig("/external_root/run/encfs_mounted") == true) {
|
|
||||||
writeFile("/external_root/run/encfs_stop_cleanup", "true");
|
|
||||||
writeFile("/opt/ibxd", "encfs_stop\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/encfs_stopped")) {
|
|
||||||
QFile::remove("/tmp/encfs_stopped");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFile("/opt/ibxd", "gui_apps_stop\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/gui_apps_stopped")) {
|
|
||||||
QFile::remove("/tmp/gui_apps_stopped");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFile("/opt/ibxd", "onboard_unmount\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/onboard_unmounted")) {
|
|
||||||
QFile::remove("/tmp/onboard_unmounted");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFile("/opt/ibxd", "usbnet_stop\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/usbnet_stopped")) {
|
|
||||||
QFile::remove("/tmp/usbnet_stopped");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(global::deviceID == "n306\n" or global::deviceID == "n249\n" or global::deviceID == "n873\n") {
|
|
||||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/fs/configfs/configfs.ko");
|
|
||||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/libcomposite.ko");
|
|
||||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/drivers/usb/gadget/function/usb_f_mass_storage.ko");
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "kt\n") {
|
|
||||||
QProcess::execute("insmod", QStringList() << "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/arcotg_udc.ko");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString prog_1 ("insmod");
|
|
||||||
QStringList args_1;
|
|
||||||
|
|
||||||
if(global::deviceID == "kt\n") {
|
|
||||||
massStorageModule = "/external_root/lib/modules/2.6.35-inkbox/kernel/drivers/usb/gadget/g_file_storage.ko";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
massStorageModule = "/external_root/lib/modules/g_mass_storage.ko";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(global::usbms::koboxExportExtensions == true) {
|
|
||||||
args_1 << massStorageModule << "file=/external_root/opt/storage/X11/extensions-user.img" << "removable=y" << "stall=0";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
args_1 << massStorageModule << "file=/external_root/opt/storage/onboard" << "removable=y" << "stall=0";
|
|
||||||
}
|
|
||||||
|
|
||||||
QProcess *proc_1 = new QProcess();
|
|
||||||
proc_1->start(prog_1, args_1);
|
|
||||||
proc_1->waitForFinished();
|
|
||||||
proc_1->deleteLater();
|
|
||||||
|
|
||||||
bool exitUsbMsDone = false;
|
|
||||||
QTimer *usbms_t = new QTimer(this);
|
|
||||||
usbms_t->setInterval(1000);
|
|
||||||
connect(usbms_t, &QTimer::timeout, [&]() {
|
|
||||||
if(exitUsbMsDone == false) {
|
|
||||||
if(isUsbPluggedIn() == 0) {
|
|
||||||
if(global::usbms::koboxExportExtensions == true) {
|
|
||||||
reboot(false);
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log("Exiting USBMS session", className);
|
|
||||||
// '<font/>' bit: because nothing else works ...
|
|
||||||
ui->label->setText("<font face='Inter'>Processing content</font>");
|
|
||||||
ui->label->setFont(QFont("Inter"));
|
|
||||||
ui->label_3->setText("Please wait");
|
|
||||||
ui->label_3->setFont(QFont("u001"));
|
|
||||||
ui->label->setStyleSheet("QLabel { background-color : black; color : white; font-size: 15pt; font-weight: bold }");
|
|
||||||
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt }");
|
|
||||||
ui->label->setFont(QFont("u001"));
|
|
||||||
|
|
||||||
float stdIconWidth = sW / 2;
|
|
||||||
float stdIconHeight = sH / 2;
|
|
||||||
|
|
||||||
QPixmap pixmap(":/resources/clock-inverted.png");
|
|
||||||
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
||||||
ui->label_2->setPixmap(scaledPixmap);
|
|
||||||
|
|
||||||
this->repaint();
|
|
||||||
|
|
||||||
QString prog("rmmod");
|
|
||||||
QStringList args;
|
|
||||||
args << massStorageModule;
|
|
||||||
QProcess * proc = new QProcess();
|
|
||||||
proc->start(prog, args);
|
|
||||||
proc->waitForFinished();
|
|
||||||
proc->deleteLater();
|
|
||||||
|
|
||||||
QTimer::singleShot(500, this, SLOT(restartServices()));
|
|
||||||
}
|
|
||||||
exitUsbMsDone = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
usbms_t->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
usbmsSplash::~usbmsSplash()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbmsSplash::brightnessDown() {
|
|
||||||
cinematicBrightness(0, 1);
|
|
||||||
writeFile("/tmp/inkbox-cinematicBrightness_ran", "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbmsSplash::warmthDown() {
|
|
||||||
if(global::deviceID == "n249\n" or global::deviceID == "n873\n") {
|
|
||||||
cinematicWarmth(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbmsSplash::quit_restart() {
|
|
||||||
// If existing, cleaning bookconfig_mount mountpoint
|
|
||||||
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
|
||||||
|
|
||||||
// Restarting InkBox
|
|
||||||
QProcess process;
|
|
||||||
process.startDetached("inkbox", QStringList());
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void usbmsSplash::restartServices() {
|
|
||||||
// Restarting USBNet
|
|
||||||
// NOTE: USBNet is only started if required conditions are met (see https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/usbnet)
|
|
||||||
writeFile("/opt/ibxd", "usbnet_start\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/usbnet_started")) {
|
|
||||||
QFile::remove("/tmp/usbnet_started");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mounting onboard storage
|
|
||||||
writeFile("/opt/ibxd", "onboard_mount\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/onboard_mounted")) {
|
|
||||||
QFile::remove("/tmp/onboard_mounted");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking for updates
|
|
||||||
writeFile("/opt/ibxd", "update_inkbox_restart\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/update_inkbox_restarted")) {
|
|
||||||
QFile::remove("/tmp/update_inkbox_restarted");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile::remove("/tmp/in_usbms");
|
|
||||||
// GUI apps: update main JSON file
|
|
||||||
writeFile("/opt/ibxd", "gui_apps_start\n");
|
|
||||||
while(true) {
|
|
||||||
if(QFile::exists("/tmp/gui_apps_started")) {
|
|
||||||
if(checkconfig("/tmp/gui_apps_started") == true) {
|
|
||||||
QFile::remove("/tmp/gui_apps_started");
|
|
||||||
updateUserAppsMainJsonFile();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log("GUI apps service failed to start", className);
|
|
||||||
QFile::remove("/tmp/gui_apps_started");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
// Remove macOS dotfiles
|
|
||||||
{
|
|
||||||
QString prog("busybox-initrd");
|
|
||||||
QStringList args;
|
|
||||||
args << "find" << "/mnt/onboard/onboard" << "-type" << "f" << "-name" << "._*" << "-delete";
|
|
||||||
QProcess * proc = new QProcess();
|
|
||||||
proc->start(prog, args);
|
|
||||||
proc->waitForFinished();
|
|
||||||
proc->deleteLater();
|
|
||||||
}
|
|
||||||
// Re-generate local library on next launch
|
|
||||||
QFile::remove(global::localLibrary::databasePath);
|
|
||||||
|
|
||||||
quit_restart();
|
|
||||||
}
|
|
|
@ -1,16 +1,19 @@
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
telemetry::telemetry(QObject *parent)
|
Telemetry::Telemetry(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
QTimer::singleShot(100, this, SLOT(telemetrySlot()));
|
QTimer::singleShot(100, this, SLOT(telemetrySlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject telemetry::collectDeviceInformation() {
|
QJsonObject Telemetry::collectDeviceInformation() {
|
||||||
|
Device::SysInfo info = Device::getSingleton()->getSystemInfo();
|
||||||
|
|
||||||
QJsonObject data;
|
QJsonObject data;
|
||||||
data.insert("DeviceUID", getUID());
|
data.insert("DeviceUID", info.uid);
|
||||||
data.insert("SystemVersion", readFile("/opt/version").trimmed());
|
data.insert("SystemVersion", readFile("/opt/version").trimmed());
|
||||||
data.insert("Device", global::deviceID.trimmed());
|
data.insert("Device", Device::getSingleton()->getID());
|
||||||
if(checkconfig("/external_root/opt/root/rooted")) {
|
if(checkconfig("/external_root/opt/root/rooted")) {
|
||||||
data.insert("DeviceRooted", "true");
|
data.insert("DeviceRooted", "true");
|
||||||
}
|
}
|
||||||
|
@ -27,7 +30,7 @@ QJsonObject telemetry::collectDeviceInformation() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool telemetry::sendDeviceInformation(QJsonObject data) {
|
bool Telemetry::sendDeviceInformation(QJsonObject data) {
|
||||||
log("Telemetry data to be sent to server: " + QJsonDocument(data).toJson(QJsonDocument::Compact), className);
|
log("Telemetry data to be sent to server: " + QJsonDocument(data).toJson(QJsonDocument::Compact), className);
|
||||||
|
|
||||||
// NOTE: This URL *will* change in the future
|
// NOTE: This URL *will* change in the future
|
||||||
|
@ -46,7 +49,7 @@ bool telemetry::sendDeviceInformation(QJsonObject data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void telemetry::telemetrySlot() {
|
void Telemetry::telemetrySlot() {
|
||||||
QJsonObject data = collectDeviceInformation();
|
QJsonObject data = collectDeviceInformation();
|
||||||
if(sendDeviceInformation(data)) {
|
if(sendDeviceInformation(data)) {
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
class telemetry : public QObject
|
class Telemetry : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit telemetry(QObject *parent = nullptr);
|
explicit Telemetry(QObject *parent = nullptr);
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
QString message;
|
QString message;
|
||||||
QString deviceUID;
|
QString deviceUID;
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include "ui_apps.h"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "ui_apps.h"
|
||||||
#include "userapps.h"
|
#include "userapps.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
|
||||||
#include <QJsonParseError>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonValue>
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QProcess>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
apps::apps(QWidget *parent) :
|
AppsWidget::AppsWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::apps)
|
ui(new Ui::AppsWidget) {
|
||||||
{
|
Device *device = Device::getSingleton();
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->koboxAppsOpenButton->setProperty("type", "borderless");
|
ui->koboxAppsOpenButton->setProperty("type", "borderless");
|
||||||
ui->calendarLaunchBtn->setProperty("type", "borderless");
|
ui->calendarLaunchBtn->setProperty("type", "borderless");
|
||||||
|
@ -46,14 +48,13 @@ apps::apps(QWidget *parent) :
|
||||||
}
|
}
|
||||||
// Hiding VNC viewer button and label if device is not rooted and doesn't have a working Wi-Fi adapter, or if X11 is not running
|
// Hiding VNC viewer button and label if device is not rooted and doesn't have a working Wi-Fi adapter, or if X11 is not running
|
||||||
if (checkconfig("/external_root/opt/root/rooted") == false) {
|
if (checkconfig("/external_root/opt/root/rooted") == false) {
|
||||||
if(global::device::isWifiAble == false or checkconfig("/external_root/boot/flags/X11_START") == false or checkconfig("/external_root/boot/flags/X11_STARTED") == false) {
|
if (device->supportsWifi() == false or checkconfig("/external_root/boot/flags/X11_START") == false or checkconfig("/external_root/boot/flags/X11_STARTED") == false) {
|
||||||
ui->vncViewerLabel->hide();
|
ui->vncViewerLabel->hide();
|
||||||
ui->vncLaunchBtn->hide();
|
ui->vncLaunchBtn->hide();
|
||||||
ui->vncViewerLabel->deleteLater();
|
ui->vncViewerLabel->deleteLater();
|
||||||
ui->vncLaunchBtn->deleteLater();
|
ui->vncLaunchBtn->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (checkconfig("/external_root/boot/flags/X11_START") == false or checkconfig("/external_root/boot/flags/X11_STARTED") == false) {
|
if (checkconfig("/external_root/boot/flags/X11_START") == false or checkconfig("/external_root/boot/flags/X11_STARTED") == false) {
|
||||||
ui->vncViewerLabel->hide();
|
ui->vncViewerLabel->hide();
|
||||||
ui->vncLaunchBtn->hide();
|
ui->vncLaunchBtn->hide();
|
||||||
|
@ -71,94 +72,83 @@ apps::apps(QWidget *parent) :
|
||||||
jsonParseSuccess = parseJson();
|
jsonParseSuccess = parseJson();
|
||||||
showUserApps(false);
|
showUserApps(false);
|
||||||
|
|
||||||
QFile stylesheetFile("/mnt/onboard/.adds/inkbox/eink.qss");
|
UI::applyStyle(*this, "eink");
|
||||||
stylesheetFile.open(QFile::ReadOnly);
|
|
||||||
this->setStyleSheet(stylesheetFile.readAll());
|
|
||||||
stylesheetFile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apps::~apps()
|
AppsWidget::~AppsWidget() {
|
||||||
{
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::exitSlot() {
|
void AppsWidget::exitSlot() {
|
||||||
apps::close();
|
AppsWidget::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_savedWordsLaunchBtn_clicked()
|
void AppsWidget::on_savedWordsLaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Launching Saved Words app", className);
|
log("Launching Saved Words app", className);
|
||||||
savedWordsWindow = new savedwords();
|
savedWordsWindow = new SavedWordsAppWidget();
|
||||||
savedWordsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
savedWordsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
savedWordsWindow->showFullScreen();
|
savedWordsWindow->showFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_calendarLaunchBtn_clicked()
|
void AppsWidget::on_calendarLaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Launching Calendar app", className);
|
log("Launching Calendar app", className);
|
||||||
calendarWindow = new calendarApp();
|
calendarWindow = new CalendarAppWidget();
|
||||||
calendarWindow->setAttribute(Qt::WA_DeleteOnClose);
|
calendarWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
calendarWindow->showFullScreen();
|
calendarWindow->showFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_calculatorLaunchBtn_clicked()
|
void AppsWidget::on_calculatorLaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Launching external Qalculate! app", className);
|
log("Launching external Qalculate! app", className);
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.startDetached("qalculate", QStringList());
|
process.startDetached("qalculate", QStringList());
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_koboxAppsOpenButton_clicked()
|
void AppsWidget::on_koboxAppsOpenButton_clicked() {
|
||||||
{
|
|
||||||
log("Showing KoBox Apps Dialog", className);
|
log("Showing KoBox Apps Dialog", className);
|
||||||
koboxAppsDialogWindow = new koboxAppsDialog();
|
koboxAppsDialogWindow = new KoboxAppsDialog();
|
||||||
connect(koboxAppsDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
connect(koboxAppsDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
||||||
koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
koboxAppsDialogWindow->show();
|
koboxAppsDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_vncLaunchBtn_clicked()
|
void AppsWidget::on_vncLaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Showing VNC dialog", className);
|
log("Showing VNC dialog", className);
|
||||||
global::keyboard::keyboardDialog = true;
|
global::keyboard::keyboardDialog = true;
|
||||||
global::keyboard::vncDialog = true;
|
global::keyboard::vncDialog = true;
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new GeneralDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreenNative()));
|
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreenNative()));
|
||||||
generalDialogWindow->show();
|
generalDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::refreshScreenNative() {
|
void AppsWidget::refreshScreenNative() {
|
||||||
emit refreshScreen();
|
emit refreshScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_reversiLaunchBtn_clicked()
|
void AppsWidget::on_reversiLaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Launching external Reversi app", className);
|
log("Launching external Reversi app", className);
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.startDetached("qreversi", QStringList());
|
process.startDetached("qreversi", QStringList());
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_g2048LaunchBtn_clicked()
|
void AppsWidget::on_g2048LaunchBtn_clicked() {
|
||||||
{
|
|
||||||
log("Launching external 2048 app", className);
|
log("Launching external 2048 app", className);
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.startDetached("2048", QStringList());
|
process.startDetached("2048", QStringList());
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::showToastNative(QString messageToDisplay) {
|
void AppsWidget::showToastNative(QString messageToDisplay) {
|
||||||
emit showToast(messageToDisplay);
|
emit showToast(messageToDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function opens and reads the main GUI user applications' JSON file, parses and verifies its contents to avoid issues in the future.
|
* This function opens and reads the main GUI user applications' JSON file, parses and verifies its contents to avoid issues in the future.
|
||||||
*/
|
*/
|
||||||
bool apps::parseJson() {
|
bool AppsWidget::parseJson() {
|
||||||
// If the path changes, it is also used statically in showUserApps()
|
// If the path changes, it is also used statically in showUserApps()
|
||||||
jsonFile.setFileName("/mnt/onboard/onboard/.apps/apps.json");
|
jsonFile.setFileName("/mnt/onboard/onboard/.apps/apps.json");
|
||||||
bool jsonCheckSuccess = true;
|
bool jsonCheckSuccess = true;
|
||||||
|
@ -166,8 +156,7 @@ bool apps::parseJson() {
|
||||||
if (jsonFile.exists() == false) {
|
if (jsonFile.exists() == false) {
|
||||||
log("GUI user applications' main JSON file is missing", className);
|
log("GUI user applications' main JSON file is missing", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
QString fileRead = jsonFile.readAll();
|
QString fileRead = jsonFile.readAll();
|
||||||
jsonFile.close();
|
jsonFile.close();
|
||||||
|
@ -176,8 +165,7 @@ bool apps::parseJson() {
|
||||||
if (jsonDocument.isNull() == true) {
|
if (jsonDocument.isNull() == true) {
|
||||||
log("GUI user applications' main JSON file is invalid", className);
|
log("GUI user applications' main JSON file is invalid", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QJsonObject jsonObject = jsonDocument.object();
|
QJsonObject jsonObject = jsonDocument.object();
|
||||||
if (jsonObject["list"].isArray() == true) {
|
if (jsonObject["list"].isArray() == true) {
|
||||||
QJsonArray jsonArray = jsonObject["list"].toArray();
|
QJsonArray jsonArray = jsonObject["list"].toArray();
|
||||||
|
@ -186,87 +174,89 @@ bool apps::parseJson() {
|
||||||
QJsonObject jsonMainObject = refJsonObject.toObject();
|
QJsonObject jsonMainObject = refJsonObject.toObject();
|
||||||
if (jsonMainObject.size() == 9) {
|
if (jsonMainObject.size() == 9) {
|
||||||
if (!jsonMainObject["Name"].isString()) {
|
if (!jsonMainObject["Name"].isString()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'Name' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'Name' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["Author"].isString()) {
|
if (!jsonMainObject["Author"].isString()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'Author' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'Author' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["AuthorContact"].isString()) {
|
if (!jsonMainObject["AuthorContact"].isString()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'AuthorContact' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'AuthorContact' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["Version"].isString()) {
|
if (!jsonMainObject["Version"].isString()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'Version' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'Version' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["IconPath"].isString()) {
|
if (!jsonMainObject["IconPath"].isString()) {
|
||||||
log("JSON: Invalid IconPath type inside object", className);
|
log("JSON: Invalid IconPath type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["ExecPath"].isString()) {
|
if (!jsonMainObject["ExecPath"].isString()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'ExecPath' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'ExecPath' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (jsonMainObject["ExecPath"].toString().contains("..")) {
|
if (jsonMainObject["ExecPath"].toString().contains("..")) {
|
||||||
// Possible security risk
|
// Possible security risk
|
||||||
showToastNative("ERROR: 'ExecPath' has invalid path");
|
showToastNative("ERROR: 'ExecPath' has invalid path");
|
||||||
QString function = __func__; log(function + ": 'ExecPath' contains \"..\"", className);
|
QString function = __func__;
|
||||||
|
log(function + ": 'ExecPath' contains \"..\"", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["Enabled"].isBool()) {
|
if (!jsonMainObject["Enabled"].isBool()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'Enabled' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'Enabled' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["SupportedDevices"].isArray()) {
|
if (!jsonMainObject["SupportedDevices"].isArray()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'SupportedDevices' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'SupportedDevices' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QJsonArray jsonArray = jsonMainObject["SupportedDevices"].toArray();
|
QJsonArray jsonArray = jsonMainObject["SupportedDevices"].toArray();
|
||||||
for (QJsonValueRef refJsonObject : jsonArray) {
|
for (QJsonValueRef refJsonObject : jsonArray) {
|
||||||
// https://doc.qt.io/qt-5/qjsonvalue.html#toInt
|
// https://doc.qt.io/qt-5/qjsonvalue.html#toInt
|
||||||
if (!refJsonObject.isString()) {
|
if (!refJsonObject.isString()) {
|
||||||
QString function = __func__; log(function + ": Array from 'RequiredFeatures' contains a wrong type", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Array from 'RequiredFeatures' contains a wrong type", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!jsonMainObject["RequiredFeatures"].isArray()) {
|
if (!jsonMainObject["RequiredFeatures"].isArray()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'RequiredFeatures' type inside object", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid 'RequiredFeatures' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QJsonArray jsonArray = jsonMainObject["RequiredFeatures"].toArray();
|
QJsonArray jsonArray = jsonMainObject["RequiredFeatures"].toArray();
|
||||||
for (QJsonValueRef refJsonObject : jsonArray) {
|
for (QJsonValueRef refJsonObject : jsonArray) {
|
||||||
// https://doc.qt.io/qt-5/qjsonvalue.html#toInt
|
// https://doc.qt.io/qt-5/qjsonvalue.html#toInt
|
||||||
if (!refJsonObject.isDouble()) {
|
if (!refJsonObject.isDouble()) {
|
||||||
QString function = __func__; log(function + ": Array from 'RequiredFeatures' contains a wrong type", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Array from 'RequiredFeatures' contains a wrong type", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; QString message = function + ": An object inside list array has too many items (or not enough): ";
|
QString message = function + ": An object inside list array has too many items (or not enough): ";
|
||||||
message.append(QString::number(jsonMainObject.size()));
|
message.append(QString::number(jsonMainObject.size()));
|
||||||
log(message, className);
|
log(message, className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": List array has an item of other type than object", className);
|
log(function + ": List array has an item of other type than object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,8 +266,7 @@ bool apps::parseJson() {
|
||||||
return jsonCheckSuccess;
|
return jsonCheckSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_editUserAppsBtn_clicked()
|
void AppsWidget::on_editUserAppsBtn_clicked() {
|
||||||
{
|
|
||||||
if (userAppsSecondPage == false) {
|
if (userAppsSecondPage == false) {
|
||||||
userAppsSecondPage = true;
|
userAppsSecondPage = true;
|
||||||
|
|
||||||
|
@ -287,8 +276,7 @@ void apps::on_editUserAppsBtn_clicked()
|
||||||
emit showUserAppsEdit(userAppsSecondPage);
|
emit showUserAppsEdit(userAppsSecondPage);
|
||||||
|
|
||||||
QTimer::singleShot(500, this, SLOT(refreshScreenNative()));
|
QTimer::singleShot(500, this, SLOT(refreshScreenNative()));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
userAppsSecondPage = false;
|
userAppsSecondPage = false;
|
||||||
userAppsAvailable = false;
|
userAppsAvailable = false;
|
||||||
|
|
||||||
|
@ -307,18 +295,18 @@ void apps::on_editUserAppsBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::showUserApps(bool showDisabledJson)
|
void AppsWidget::showUserApps(bool showDisabledJson) {
|
||||||
{
|
|
||||||
emit clearAppsLayout();
|
emit clearAppsLayout();
|
||||||
|
|
||||||
if (jsonParseSuccess == true) {
|
if (jsonParseSuccess == true) {
|
||||||
QString function = __func__; log(function + ": Main user applications' JSON is valid", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Main user applications' JSON is valid", className);
|
||||||
QJsonArray jsonListArray = jsonDocument.object()["list"].toArray();
|
QJsonArray jsonListArray = jsonDocument.object()["list"].toArray();
|
||||||
for (QJsonValueRef refJsonObject : jsonListArray) {
|
for (QJsonValueRef refJsonObject : jsonListArray) {
|
||||||
QJsonObject appInfo = refJsonObject.toObject();
|
QJsonObject appInfo = refJsonObject.toObject();
|
||||||
if (appInfo["Enabled"].toBool() == true or showDisabledJson == true) {
|
if (appInfo["Enabled"].toBool() == true or showDisabledJson == true) {
|
||||||
userAppsAvailable = true;
|
userAppsAvailable = true;
|
||||||
userapps * newUserApp = new userapps;
|
UserAppsWidget *newUserApp = new UserAppsWidget;
|
||||||
newUserApp->provideInfo(appInfo);
|
newUserApp->provideInfo(appInfo);
|
||||||
connect(this, SIGNAL(clearAppsLayout()), newUserApp, SLOT(deleteLater()));
|
connect(this, SIGNAL(clearAppsLayout()), newUserApp, SLOT(deleteLater()));
|
||||||
connect(this, SIGNAL(showUserAppsEdit(bool)), newUserApp, SLOT(changePageEnabling(bool)));
|
connect(this, SIGNAL(showUserAppsEdit(bool)), newUserApp, SLOT(changePageEnabling(bool)));
|
||||||
|
@ -332,18 +320,17 @@ void apps::showUserApps(bool showDisabledJson)
|
||||||
|
|
||||||
if (userAppsAvailable == false) {
|
if (userAppsAvailable == false) {
|
||||||
ui->noUserAppsAvailableLabel->show();
|
ui->noUserAppsAvailableLabel->show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->noUserAppsAvailableLabel->hide();
|
ui->noUserAppsAvailableLabel->hide();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (QFile::exists("/mnt/onboard/onboard/.apps/apps.json")) {
|
if (QFile::exists("/mnt/onboard/onboard/.apps/apps.json")) {
|
||||||
QString function = __func__; log(function + ": Main user applications' JSON file is invalid", className);
|
QString function = __func__;
|
||||||
|
log(function + ": Main user applications' JSON file is invalid", className);
|
||||||
QTimer::singleShot(500, this, SLOT(showFailedToParseMainUserAppsJsonFile()));
|
QTimer::singleShot(500, this, SLOT(showFailedToParseMainUserAppsJsonFile()));
|
||||||
}
|
} else {
|
||||||
else {
|
QString function = __func__;
|
||||||
QString function = __func__; log(function + ": Main user applications' JSON file doesn't exist; assuming that no user applications are currently installed", className);
|
log(function + ": Main user applications' JSON file doesn't exist; assuming that no user applications are currently installed", className);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->editUserAppsBtn->hide();
|
ui->editUserAppsBtn->hide();
|
||||||
|
@ -358,20 +345,18 @@ void apps::showUserApps(bool showDisabledJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::updateJsonFileSlot(QJsonDocument jsonDocumentFunc)
|
void AppsWidget::updateJsonFileSlot(QJsonDocument jsonDocumentFunc) {
|
||||||
{
|
|
||||||
jsonDocument = jsonDocumentFunc;
|
jsonDocument = jsonDocumentFunc;
|
||||||
emit updateJsonFileSignal(jsonDocument);
|
emit updateJsonFileSignal(jsonDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::showFailedToParseMainUserAppsJsonFile() {
|
void AppsWidget::showFailedToParseMainUserAppsJsonFile() {
|
||||||
emit showToast("Failed to parse 'apps.json'");
|
emit showToast("Failed to parse 'apps.json'");
|
||||||
}
|
}
|
||||||
|
|
||||||
void apps::on_todoLaunchBtn_clicked()
|
void AppsWidget::on_todoLaunchBtn_clicked() {
|
||||||
{
|
TodoAppWidget *todoWindow = new TodoAppWidget();
|
||||||
todo * todoWindow = new todo();
|
QObject::connect(todoWindow, &TodoAppWidget::showToast, this, &AppsWidget::showToast);
|
||||||
QObject::connect(todoWindow, &todo::showToast, this, &apps::showToast);
|
|
||||||
todoWindow->setAttribute(Qt::WA_DeleteOnClose);
|
todoWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
todoWindow->setGeometry(QRect(QPoint(0, 0), qApp->primaryScreen()->geometry().size()));
|
todoWindow->setGeometry(QRect(QPoint(0, 0), qApp->primaryScreen()->geometry().size()));
|
||||||
todoWindow->show();
|
todoWindow->show();
|
|
@ -11,17 +11,17 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class apps;
|
class AppsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class apps : public QWidget
|
class AppsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit apps(QWidget *parent = nullptr);
|
explicit AppsWidget(QWidget *parent = nullptr);
|
||||||
~apps();
|
~AppsWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void exitSlot();
|
void exitSlot();
|
||||||
|
@ -42,12 +42,12 @@ private slots:
|
||||||
void on_todoLaunchBtn_clicked();
|
void on_todoLaunchBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::apps * ui;
|
Ui::AppsWidget * ui;
|
||||||
savedwords * savedWordsWindow;
|
SavedWordsAppWidget * savedWordsWindow;
|
||||||
calendarApp * calendarWindow;
|
CalendarAppWidget * calendarWindow;
|
||||||
koboxAppsDialog * koboxAppsDialogWindow;
|
KoboxAppsDialog * koboxAppsDialogWindow;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
todo * todoWindow;
|
TodoAppWidget * todoWindow;
|
||||||
|
|
||||||
QFile jsonFile;
|
QFile jsonFile;
|
||||||
QJsonDocument jsonDocument;
|
QJsonDocument jsonDocument;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>apps</class>
|
<class>AppsWidget</class>
|
||||||
<widget class="QWidget" name="apps">
|
<widget class="QWidget" name="AppsWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
27
src/ui/apps/calendarapp.cpp
Normal file
27
src/ui/apps/calendarapp.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "calendarapp.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_calendarapp.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
CalendarAppWidget::CalendarAppWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::CalendarAppWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
CalendarAppWidget::setFont(QFont("u001"));
|
||||||
|
ui->backBtn->setFont(QFont("Inter"));
|
||||||
|
ui->backBtn->setStyleSheet("font-weight: bold");
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
ui->backBtn->setProperty("type", "borderless");
|
||||||
|
}
|
||||||
|
|
||||||
|
CalendarAppWidget::~CalendarAppWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalendarAppWidget::on_backBtn_clicked() {
|
||||||
|
CalendarAppWidget::close();
|
||||||
|
}
|
|
@ -4,23 +4,23 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class calendarApp;
|
class CalendarAppWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class calendarApp : public QWidget
|
class CalendarAppWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit calendarApp(QWidget *parent = nullptr);
|
explicit CalendarAppWidget(QWidget *parent = nullptr);
|
||||||
~calendarApp();
|
~CalendarAppWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_backBtn_clicked();
|
void on_backBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::calendarApp *ui;
|
Ui::CalendarAppWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CALENDARAPP_H
|
#endif // CALENDARAPP_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>calendarApp</class>
|
<class>CalendarAppWidget</class>
|
||||||
<widget class="QWidget" name="calendarApp">
|
<widget class="QWidget" name="CalendarAppWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
81
src/ui/apps/savedwords.cpp
Normal file
81
src/ui/apps/savedwords.cpp
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#include "savedwords.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_savedwords.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStringListModel>
|
||||||
|
|
||||||
|
SavedWordsAppWidget::SavedWordsAppWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::SavedWordsAppWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
SavedWordsAppWidget::setFont(QFont("u001"));
|
||||||
|
ui->savedWordsLabel->setFont(QFont("Inter"));
|
||||||
|
ui->backBtn->setFont(QFont("Inter"));
|
||||||
|
ui->clearBtn->setFont(QFont("Inter"));
|
||||||
|
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
ui->backBtn->setProperty("type", "borderless");
|
||||||
|
ui->clearBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
ui->savedWordsLabel->setStyleSheet("font-weight: bold");
|
||||||
|
ui->wordsList->setStyleSheet("font-size: 10pt");
|
||||||
|
ui->backBtn->setStyleSheet("font-weight: bold");
|
||||||
|
ui->clearBtn->setStyleSheet("font-weight: bold");
|
||||||
|
|
||||||
|
checkwords();
|
||||||
|
|
||||||
|
QStringListModel *model = new QStringListModel(this);
|
||||||
|
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
||||||
|
model->setStringList(list);
|
||||||
|
ui->wordsList->setModel(model);
|
||||||
|
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
}
|
||||||
|
|
||||||
|
SavedWordsAppWidget::~SavedWordsAppWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SavedWordsAppWidget::on_backBtn_clicked() {
|
||||||
|
// Workaround for the random strange memory corruption error
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SavedWordsAppWidget::on_clearBtn_clicked() {
|
||||||
|
// Warning: possible memory leak here. Though, usually, when you press the "Clear" button and all clears up, you don't have to press it again ;)
|
||||||
|
log("Wiping Saved Words list", className);
|
||||||
|
save_word_init();
|
||||||
|
checkwords();
|
||||||
|
QStringListModel *model = new QStringListModel(this);
|
||||||
|
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
||||||
|
model->setStringList(list);
|
||||||
|
ui->wordsList->setModel(model);
|
||||||
|
ui->wordsList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SavedWordsAppWidget::checkwords() {
|
||||||
|
QFile words_list(".config/06-words/config");
|
||||||
|
words_list.open(QIODevice::ReadWrite);
|
||||||
|
QTextStream in(&words_list);
|
||||||
|
words = in.readAll();
|
||||||
|
words_list.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SavedWordsAppWidget::save_word_init() {
|
||||||
|
QFile words(".config/06-words/config");
|
||||||
|
words.open(QIODevice::ReadWrite);
|
||||||
|
QTextStream in(&words);
|
||||||
|
QString words_list = in.readAll();
|
||||||
|
string words_list_str = words_list.toStdString();
|
||||||
|
words.close();
|
||||||
|
|
||||||
|
ofstream fhandler;
|
||||||
|
fhandler.open(".config/06-words/config");
|
||||||
|
fhandler << "";
|
||||||
|
fhandler.close();
|
||||||
|
}
|
|
@ -11,17 +11,17 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class savedwords;
|
class SavedWordsAppWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class savedwords : public QWidget
|
class SavedWordsAppWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit savedwords(QWidget *parent = nullptr);
|
explicit SavedWordsAppWidget(QWidget *parent = nullptr);
|
||||||
~savedwords();
|
~SavedWordsAppWidget();
|
||||||
QString words;
|
QString words;
|
||||||
void checkwords();
|
void checkwords();
|
||||||
void save_word_init();
|
void save_word_init();
|
||||||
|
@ -31,7 +31,7 @@ private slots:
|
||||||
void on_clearBtn_clicked();
|
void on_clearBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::savedwords *ui;
|
Ui::SavedWordsAppWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SAVEDWORDS_H
|
#endif // SAVEDWORDS_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>savedwords</class>
|
<class>SavedWordsAppWidget</class>
|
||||||
<widget class="QWidget" name="savedwords">
|
<widget class="QWidget" name="SavedWordsAppWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
|
@ -1,12 +1,14 @@
|
||||||
#include "todo.h"
|
#include "todo.h"
|
||||||
#include "ui_todo.h"
|
#include "ui_todo.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
todo::todo(QWidget *parent) :
|
TodoAppWidget::TodoAppWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::todo)
|
ui(new Ui::TodoAppWidget)
|
||||||
{
|
{
|
||||||
|
Device* device = Device::getSingleton();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setStyleSheet(readFile("/mnt/onboard/.adds/inkbox/eink.qss"));
|
this->setStyleSheet(readFile("/mnt/onboard/.adds/inkbox/eink.qss"));
|
||||||
this->setFont(QFont("u001"));
|
this->setFont(QFont("u001"));
|
||||||
|
@ -17,7 +19,7 @@ todo::todo(QWidget *parent) :
|
||||||
ui->setupBtn->setEnabled(false);
|
ui->setupBtn->setEnabled(false);
|
||||||
|
|
||||||
buttonPadding;
|
buttonPadding;
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
if(device->getScreenSize() <= Device::ScreenSize::MEDIUM) {
|
||||||
buttonPadding = 5;
|
buttonPadding = 5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -66,12 +68,12 @@ todo::todo(QWidget *parent) :
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
todo::~todo()
|
TodoAppWidget::~TodoAppWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_closeBtn_clicked()
|
void TodoAppWidget::on_closeBtn_clicked()
|
||||||
{
|
{
|
||||||
if(currentView == currentView::home) {
|
if(currentView == currentView::home) {
|
||||||
this->close();
|
this->close();
|
||||||
|
@ -82,19 +84,19 @@ void todo::on_closeBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_newBtn_clicked()
|
void TodoAppWidget::on_newBtn_clicked()
|
||||||
{
|
{
|
||||||
global::keyboard::embed = false;
|
global::keyboard::embed = false;
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
||||||
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &todo::createNewList);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &TodoAppWidget::createNewList);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &todo::setDefaultHomePageStatusText);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &TodoAppWidget::setDefaultHomePageStatusText);
|
||||||
ui->statusLabel->setText("Enter the list's name");
|
ui->statusLabel->setText("Enter the list's name");
|
||||||
virtualKeyboardWidget->show();
|
virtualKeyboardWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::createNewList(QString listName) {
|
void TodoAppWidget::createNewList(QString listName) {
|
||||||
log("Initializing new To-Do list with name '" + listName + "'", className);
|
log("Initializing new To-Do list with name '" + listName + "'", className);
|
||||||
QJsonDocument document;
|
QJsonDocument document;
|
||||||
QJsonArray mainArray;
|
QJsonArray mainArray;
|
||||||
|
@ -117,7 +119,7 @@ void todo::createNewList(QString listName) {
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::addItem(QString itemName) {
|
void TodoAppWidget::addItem(QString itemName) {
|
||||||
log("Adding item with name '" + itemName + "' to current list", className);
|
log("Adding item with name '" + itemName + "' to current list", className);
|
||||||
// Accessing the current list's items array
|
// Accessing the current list's items array
|
||||||
QJsonDocument document = readTodoDatabase();
|
QJsonDocument document = readTodoDatabase();
|
||||||
|
@ -142,7 +144,7 @@ void todo::addItem(QString itemName) {
|
||||||
setupList(listArray.at(0).toString());
|
setupList(listArray.at(0).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::refreshList() {
|
void TodoAppWidget::refreshList() {
|
||||||
if(QFile::exists(global::localLibrary::todoDatabasePath)) {
|
if(QFile::exists(global::localLibrary::todoDatabasePath)) {
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
QJsonArray array = readTodoDatabase().object()["List"].toArray();
|
QJsonArray array = readTodoDatabase().object()["List"].toArray();
|
||||||
|
@ -155,7 +157,7 @@ void todo::refreshList() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::setupList(QString listName) {
|
void TodoAppWidget::setupList(QString listName) {
|
||||||
log("Setting up list with name '" + listName + "'", className);
|
log("Setting up list with name '" + listName + "'", className);
|
||||||
QJsonArray array = readTodoDatabase().object()["List"].toArray();
|
QJsonArray array = readTodoDatabase().object()["List"].toArray();
|
||||||
// Iterate through the To-Do lists array to find the list's array index
|
// Iterate through the To-Do lists array to find the list's array index
|
||||||
|
@ -197,7 +199,7 @@ void todo::setupList(QString listName) {
|
||||||
ui->statusLabel->setText("Select or create a new item");
|
ui->statusLabel->setText("Select or create a new item");
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_setupBtn_clicked()
|
void TodoAppWidget::on_setupBtn_clicked()
|
||||||
{
|
{
|
||||||
ui->deleteBtn->setEnabled(false);
|
ui->deleteBtn->setEnabled(false);
|
||||||
ui->setupBtn->setEnabled(false);
|
ui->setupBtn->setEnabled(false);
|
||||||
|
@ -205,13 +207,13 @@ void todo::on_setupBtn_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void todo::on_listWidget_itemClicked(QListWidgetItem *item)
|
void TodoAppWidget::on_listWidget_itemClicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
ui->deleteBtn->setEnabled(true);
|
ui->deleteBtn->setEnabled(true);
|
||||||
ui->setupBtn->setEnabled(true);
|
ui->setupBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::saveCurrentList() {
|
void TodoAppWidget::saveCurrentList() {
|
||||||
QJsonDocument document = readTodoDatabase();
|
QJsonDocument document = readTodoDatabase();
|
||||||
QJsonObject object = document.object();
|
QJsonObject object = document.object();
|
||||||
QJsonArray mainArray = object["List"].toArray();
|
QJsonArray mainArray = object["List"].toArray();
|
||||||
|
@ -235,7 +237,7 @@ void todo::saveCurrentList() {
|
||||||
writeTodoDatabase(document);
|
writeTodoDatabase(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_deleteBtn_clicked()
|
void TodoAppWidget::on_deleteBtn_clicked()
|
||||||
{
|
{
|
||||||
QJsonDocument document = readTodoDatabase();
|
QJsonDocument document = readTodoDatabase();
|
||||||
QJsonObject object = document.object();
|
QJsonObject object = document.object();
|
||||||
|
@ -251,19 +253,19 @@ void todo::on_deleteBtn_clicked()
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_newItemBtn_clicked()
|
void TodoAppWidget::on_newItemBtn_clicked()
|
||||||
{
|
{
|
||||||
global::keyboard::embed = false;
|
global::keyboard::embed = false;
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
||||||
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &todo::addItem);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &TodoAppWidget::addItem);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &todo::setDefaultListPageStatusText);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &TodoAppWidget::setDefaultListPageStatusText);
|
||||||
ui->statusLabel->setText("Enter the item's name");
|
ui->statusLabel->setText("Enter the item's name");
|
||||||
virtualKeyboardWidget->show();
|
virtualKeyboardWidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::switchViewHome() {
|
void TodoAppWidget::switchViewHome() {
|
||||||
ui->itemsListWidget->clear();
|
ui->itemsListWidget->clear();
|
||||||
switchItemsSelectionMode(false);
|
switchItemsSelectionMode(false);
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
@ -276,7 +278,7 @@ void todo::switchViewHome() {
|
||||||
currentView = currentView::home;
|
currentView = currentView::home;
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_selectItemsModeBtn_clicked()
|
void TodoAppWidget::on_selectItemsModeBtn_clicked()
|
||||||
{
|
{
|
||||||
if(selectItemsMode == false) {
|
if(selectItemsMode == false) {
|
||||||
switchItemsSelectionMode(true);
|
switchItemsSelectionMode(true);
|
||||||
|
@ -286,7 +288,7 @@ void todo::on_selectItemsModeBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::switchItemsSelectionMode(bool selectionMode) {
|
void TodoAppWidget::switchItemsSelectionMode(bool selectionMode) {
|
||||||
if(selectionMode == true) {
|
if(selectionMode == true) {
|
||||||
log("Entering selection mode", className);
|
log("Entering selection mode", className);
|
||||||
saveCurrentList();
|
saveCurrentList();
|
||||||
|
@ -308,7 +310,7 @@ void todo::switchItemsSelectionMode(bool selectionMode) {
|
||||||
QTimer::singleShot(500, this, SLOT(resize()));
|
QTimer::singleShot(500, this, SLOT(resize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_deleteItemBtn_clicked()
|
void TodoAppWidget::on_deleteItemBtn_clicked()
|
||||||
{
|
{
|
||||||
QList<int> itemsToDelete;
|
QList<int> itemsToDelete;
|
||||||
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
||||||
|
@ -350,7 +352,7 @@ void todo::on_deleteItemBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_selectAllItemsBtn_clicked()
|
void TodoAppWidget::on_selectAllItemsBtn_clicked()
|
||||||
{
|
{
|
||||||
int range = ui->itemsListWidget->count();
|
int range = ui->itemsListWidget->count();
|
||||||
for(int i = 0; i < range; i++) {
|
for(int i = 0; i < range; i++) {
|
||||||
|
@ -358,15 +360,15 @@ void todo::on_selectAllItemsBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::setDefaultHomePageStatusText() {
|
void TodoAppWidget::setDefaultHomePageStatusText() {
|
||||||
ui->statusLabel->setText("Select or create a new list");
|
ui->statusLabel->setText("Select or create a new list");
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::setDefaultListPageStatusText() {
|
void TodoAppWidget::setDefaultListPageStatusText() {
|
||||||
ui->statusLabel->setText("Select or create a new item");
|
ui->statusLabel->setText("Select or create a new item");
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_deselectAllItemsBtn_clicked()
|
void TodoAppWidget::on_deselectAllItemsBtn_clicked()
|
||||||
{
|
{
|
||||||
int range = ui->itemsListWidget->count();
|
int range = ui->itemsListWidget->count();
|
||||||
for(int i = 0; i < range; i++) {
|
for(int i = 0; i < range; i++) {
|
||||||
|
@ -374,13 +376,13 @@ void todo::on_deselectAllItemsBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_saveCurrentListViewBtn_clicked()
|
void TodoAppWidget::on_saveCurrentListViewBtn_clicked()
|
||||||
{
|
{
|
||||||
saveCurrentList();
|
saveCurrentList();
|
||||||
switchItemsSelectionMode(false);
|
switchItemsSelectionMode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_editItemBtn_clicked()
|
void TodoAppWidget::on_editItemBtn_clicked()
|
||||||
{
|
{
|
||||||
QList<int> selectedItems;
|
QList<int> selectedItems;
|
||||||
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
||||||
|
@ -395,8 +397,8 @@ void todo::on_editItemBtn_clicked()
|
||||||
global::keyboard::keyboardText = ui->itemsListWidget->item(currentEditItemIndex - 1)->text();
|
global::keyboard::keyboardText = ui->itemsListWidget->item(currentEditItemIndex - 1)->text();
|
||||||
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this);
|
||||||
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &todo::editItemWrapper);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &TodoAppWidget::editItemWrapper);
|
||||||
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &todo::setDefaultListPageStatusText);
|
QObject::connect(virtualKeyboardWidget, &virtualkeyboard::closeBtnPressed, this, &TodoAppWidget::setDefaultListPageStatusText);
|
||||||
ui->statusLabel->setText("Enter the edited item's name");
|
ui->statusLabel->setText("Enter the edited item's name");
|
||||||
virtualKeyboardWidget->show();
|
virtualKeyboardWidget->show();
|
||||||
}
|
}
|
||||||
|
@ -410,7 +412,7 @@ void todo::on_editItemBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::editItem(int index, QString replacement) {
|
void TodoAppWidget::editItem(int index, QString replacement) {
|
||||||
QJsonDocument document = readTodoDatabase();
|
QJsonDocument document = readTodoDatabase();
|
||||||
QJsonObject object = document.object();
|
QJsonObject object = document.object();
|
||||||
QJsonArray mainArray = object["List"].toArray();
|
QJsonArray mainArray = object["List"].toArray();
|
||||||
|
@ -430,17 +432,17 @@ void todo::editItem(int index, QString replacement) {
|
||||||
setupList(listArray.at(0).toString());
|
setupList(listArray.at(0).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::editItemWrapper(QString replacement) {
|
void TodoAppWidget::editItemWrapper(QString replacement) {
|
||||||
editItem(currentEditItemIndex, replacement);
|
editItem(currentEditItemIndex, replacement);
|
||||||
currentEditItemIndex = NULL;
|
currentEditItemIndex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::resize() {
|
void TodoAppWidget::resize() {
|
||||||
this->setGeometry(QRect(QPoint(0,0), qApp->primaryScreen()->geometry().size()));
|
this->setGeometry(QRect(QPoint(0,0), qApp->primaryScreen()->geometry().size()));
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void todo::on_itemsListWidget_itemClicked(QListWidgetItem *item)
|
void TodoAppWidget::on_itemsListWidget_itemClicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
if(item->checkState() == Qt::Unchecked) {
|
if(item->checkState() == Qt::Unchecked) {
|
||||||
item->setCheckState(Qt::Checked);
|
item->setCheckState(Qt::Checked);
|
|
@ -8,17 +8,17 @@
|
||||||
#include "virtualkeyboard.h"
|
#include "virtualkeyboard.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class todo;
|
class TodoAppWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class todo : public QWidget
|
class TodoAppWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit todo(QWidget *parent = nullptr);
|
explicit TodoAppWidget(QWidget *parent = nullptr);
|
||||||
~todo();
|
~TodoAppWidget();
|
||||||
enum class currentView {
|
enum class currentView {
|
||||||
home,
|
home,
|
||||||
list
|
list
|
||||||
|
@ -61,7 +61,7 @@ signals:
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::todo *ui;
|
Ui::TodoAppWidget *ui;
|
||||||
virtualkeyboard * virtualKeyboardWidget;
|
virtualkeyboard * virtualKeyboardWidget;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>todo</class>
|
<class>TodoAppWidget</class>
|
||||||
<widget class="QWidget" name="todo">
|
<widget class="QWidget" name="TodoAppWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
|
@ -3,9 +3,9 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "generaldialog.h"
|
#include "generaldialog.h"
|
||||||
|
|
||||||
userapps::userapps(QWidget *parent) :
|
UserAppsWidget::UserAppsWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::userapps)
|
ui(new Ui::UserAppsWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->launchBtn->setProperty("type", "borderless");
|
ui->launchBtn->setProperty("type", "borderless");
|
||||||
|
@ -21,12 +21,12 @@ userapps::userapps(QWidget *parent) :
|
||||||
ui->statusBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
|
ui->statusBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
|
||||||
}
|
}
|
||||||
|
|
||||||
userapps::~userapps()
|
UserAppsWidget::~UserAppsWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void userapps::provideInfo(QJsonObject jsonInfo)
|
void UserAppsWidget::provideInfo(QJsonObject jsonInfo)
|
||||||
{
|
{
|
||||||
QString name = jsonInfo["Name"].toString();
|
QString name = jsonInfo["Name"].toString();
|
||||||
appName = name; // It is for searching for json entry while disabling / enabling
|
appName = name; // It is for searching for json entry while disabling / enabling
|
||||||
|
@ -67,7 +67,7 @@ void userapps::provideInfo(QJsonObject jsonInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is needed when we dont want to repaint all widgets, but only change the the page (when no changes to the main JSON file were applied)
|
// This function is needed when we dont want to repaint all widgets, but only change the the page (when no changes to the main JSON file were applied)
|
||||||
void userapps::changePageEnabling(bool SecondPage)
|
void UserAppsWidget::changePageEnabling(bool SecondPage)
|
||||||
{
|
{
|
||||||
if(SecondPage == true){
|
if(SecondPage == true){
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
@ -77,7 +77,7 @@ void userapps::changePageEnabling(bool SecondPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void userapps::on_infoBtn_clicked()
|
void UserAppsWidget::on_infoBtn_clicked()
|
||||||
{
|
{
|
||||||
log("Launching user application information dialog", className);
|
log("Launching user application information dialog", className);
|
||||||
// https://stackoverflow.com/questions/28181627/how-to-convert-a-qjsonobject-to-qstring
|
// https://stackoverflow.com/questions/28181627/how-to-convert-a-qjsonobject-to-qstring
|
||||||
|
@ -85,12 +85,12 @@ void userapps::on_infoBtn_clicked()
|
||||||
global::text::textBrowserContents = jsonStringParsed;
|
global::text::textBrowserContents = jsonStringParsed;
|
||||||
|
|
||||||
global::userApps::appInfoDialog = true;
|
global::userApps::appInfoDialog = true;
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new GeneralDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
generalDialogWindow->show();
|
generalDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void userapps::on_statusBtn_clicked()
|
void UserAppsWidget::on_statusBtn_clicked()
|
||||||
{
|
{
|
||||||
ui->statusBtn->setEnabled(false);
|
ui->statusBtn->setEnabled(false);
|
||||||
|
|
||||||
|
@ -129,22 +129,22 @@ void userapps::on_statusBtn_clicked()
|
||||||
ui->statusBtn->setEnabled(true);
|
ui->statusBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void userapps::updateJsonFileSlotUA(QJsonDocument jsonDocumentProvided)
|
void UserAppsWidget::updateJsonFileSlotUA(QJsonDocument jsonDocumentProvided)
|
||||||
{
|
{
|
||||||
jsonDocument = jsonDocumentProvided;
|
jsonDocument = jsonDocumentProvided;
|
||||||
}
|
}
|
||||||
|
|
||||||
void userapps::on_launchBtn_clicked()
|
void UserAppsWidget::on_launchBtn_clicked()
|
||||||
{
|
{
|
||||||
// Some command to execute script or binary at "ExecPath"
|
// Some command to execute script or binary at "ExecPath"
|
||||||
QJsonArray supportedDevices = jsonObject["SupportedDevices"].toArray();
|
QJsonArray supportedDevices = jsonObject["SupportedDevices"].toArray();
|
||||||
|
|
||||||
// This will work even if we are looking for 'n306' and there is a device named 'n306b' because QJsonArray::contains() works that way
|
// This will work even if we are looking for 'n306' and there is a device named 'n306b' because QJsonArray::contains() works that way
|
||||||
if(supportedDevices.contains("all") == false and supportedDevices.contains(global::deviceID.trimmed()) == false) {
|
if(supportedDevices.contains("all") == false and supportedDevices.contains(Device::getSingleton()->getID()) == false) {
|
||||||
log("Warning: User application '" + appName + "' does not support this device", className);
|
log("Warning: User application '" + appName + "' does not support this device", className);
|
||||||
global::userApps::appCompatibilityDialog = true;
|
global::userApps::appCompatibilityDialog = true;
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>Your device is not compatible with this app.<br>Continue anyway</font><font face='Inter'>?</font>";
|
global::userApps::appCompatibilityText = "<font face='u001'>Your device is not compatible with this app.<br>Continue anyway</font><font face='Inter'>?</font>";
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new GeneralDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
generalDialogWindow->exec();
|
generalDialogWindow->exec();
|
||||||
|
@ -173,7 +173,7 @@ void userapps::on_launchBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool userapps::manageRequiredFeatures()
|
bool UserAppsWidget::manageRequiredFeatures()
|
||||||
{
|
{
|
||||||
// This should be already set to 'true', but just in case
|
// This should be already set to 'true', but just in case
|
||||||
global::userApps::appCompatibilityLastContinueStatus = true;
|
global::userApps::appCompatibilityLastContinueStatus = true;
|
||||||
|
@ -183,13 +183,11 @@ bool userapps::manageRequiredFeatures()
|
||||||
int featureId = refJsonObject.toInt();
|
int featureId = refJsonObject.toInt();
|
||||||
// Wi-Fi connection required
|
// Wi-Fi connection required
|
||||||
if(featureId == 0) {
|
if(featureId == 0) {
|
||||||
// Double 'if' conditions to avoid launching unnecesery testPing() in emu
|
|
||||||
if(global::deviceID != "emu\n") {
|
|
||||||
if(checkWifiState() != global::wifi::wifiState::configured) {
|
if(checkWifiState() != global::wifi::wifiState::configured) {
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a Wi-Fi connection, continue anyway</font><font face='Inter'>?</font>";
|
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a Wi-Fi connection, continue anyway</font><font face='Inter'>?</font>";
|
||||||
launchDialog = true;
|
launchDialog = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Rooted kernel required
|
// Rooted kernel required
|
||||||
if(featureId == 1) {
|
if(featureId == 1) {
|
||||||
|
@ -202,7 +200,7 @@ bool userapps::manageRequiredFeatures()
|
||||||
|
|
||||||
if(launchDialog == true) {
|
if(launchDialog == true) {
|
||||||
global::userApps::appCompatibilityDialog = true;
|
global::userApps::appCompatibilityDialog = true;
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new GeneralDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
generalDialogWindow->exec();
|
generalDialogWindow->exec();
|
||||||
}
|
}
|
||||||
|
@ -214,7 +212,7 @@ bool userapps::manageRequiredFeatures()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString userapps::parseJsonShow(QJsonObject json)
|
QString UserAppsWidget::parseJsonShow(QJsonObject json)
|
||||||
{
|
{
|
||||||
QString mainString;
|
QString mainString;
|
||||||
foreach(const QString& key, json.keys()) {
|
foreach(const QString& key, json.keys()) {
|
|
@ -13,17 +13,17 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class userapps;
|
class UserAppsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class userapps : public QWidget
|
class UserAppsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit userapps(QWidget * parent = nullptr);
|
explicit UserAppsWidget(QWidget * parent = nullptr);
|
||||||
~userapps();
|
~UserAppsWidget();
|
||||||
QJsonDocument jsonDocument; // TODO: Optimize for RAM usage
|
QJsonDocument jsonDocument; // TODO: Optimize for RAM usage
|
||||||
QJsonObject jsonObject; // Needed for 'App info' button
|
QJsonObject jsonObject; // Needed for 'App info' button
|
||||||
QString jsonFilePath;
|
QString jsonFilePath;
|
||||||
|
@ -46,8 +46,8 @@ private slots:
|
||||||
void on_launchBtn_clicked();
|
void on_launchBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::userapps * ui;
|
Ui::UserAppsWidget * ui;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
|
|
||||||
QDir appDir;
|
QDir appDir;
|
||||||
QFile execPath;
|
QFile execPath;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>userapps</class>
|
<class>UserAppsWidget</class>
|
||||||
<widget class="QWidget" name="userapps">
|
<widget class="QWidget" name="UserAppsWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
360
src/ui/crypto/encryptionmanager.cpp
Normal file
360
src/ui/crypto/encryptionmanager.cpp
Normal file
|
@ -0,0 +1,360 @@
|
||||||
|
#include "encryptionmanager.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_encryptionmanager.h"
|
||||||
|
|
||||||
|
#include "functions.h"
|
||||||
|
#include "usbmsSplash.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
CryptoManagerWidget::CryptoManagerWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::CryptoManagerWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->descriptionLabel->setFont(QFont("u001"));
|
||||||
|
ui->successDescriptionLabel->setFont(QFont("u001"));
|
||||||
|
ui->failureDescriptionLabel->setFont(QFont("u001"));
|
||||||
|
ui->warningDescriptionLabel->setFont(QFont("u001"));
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
ui->encryptionSetupLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
||||||
|
ui->descriptionLabel->setStyleSheet("font-size: 10pt");
|
||||||
|
ui->successLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
||||||
|
ui->successDescriptionLabel->setStyleSheet("font-size: 10pt");
|
||||||
|
ui->failureLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
||||||
|
ui->failureDescriptionLabel->setStyleSheet("font-size: 10pt");
|
||||||
|
ui->setupContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->setupAbortBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->exitSuccessBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->failureContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->acceptBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->usbmsBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
|
||||||
|
ui->warningLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
|
||||||
|
ui->warningDescriptionLabel->setStyleSheet("font-size: 10pt");
|
||||||
|
|
||||||
|
// Getting the screen's size
|
||||||
|
float sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
float sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
float stdIconWidth;
|
||||||
|
float stdIconHeight;
|
||||||
|
{
|
||||||
|
stdIconWidth = sW / 1.50;
|
||||||
|
stdIconHeight = sH / 1.50;
|
||||||
|
QPixmap pixmap(":/resources/encryption.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->encryptionImageLabel->setPixmap(scaledPixmap);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stdIconWidth = sW / 1.65;
|
||||||
|
stdIconHeight = sH / 1.65;
|
||||||
|
QPixmap pixmap(":/resources/check-display.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->checkImageLabel->setPixmap(scaledPixmap);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stdIconWidth = sW / 1.65;
|
||||||
|
stdIconHeight = sH / 1.65;
|
||||||
|
QPixmap pixmap(":/resources/error.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->failureImageLabel->setPixmap(scaledPixmap);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stdIconWidth = sW / 1.50;
|
||||||
|
stdIconHeight = sH / 1.50;
|
||||||
|
QPixmap pixmap(":/resources/alert-triangle.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->warningImageLabel->setPixmap(scaledPixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
hourglassAnimationWidgetWindow = new hourglassAnimationWidget();
|
||||||
|
ui->hourglassWidget->insertWidget(0, hourglassAnimationWidgetWindow);
|
||||||
|
ui->hourglassWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
|
setDefaultWorkDir();
|
||||||
|
if (checkconfig(".config/18-encrypted_storage/initial_setup_done") == true or checkconfig("/external_root/run/encfs_repack") == true) {
|
||||||
|
ui->activityWidget->hide();
|
||||||
|
if (checkconfig("/external_root/run/encfs_repack") == false) {
|
||||||
|
setupPassphraseDialogMode = 1;
|
||||||
|
} else {
|
||||||
|
setupPassphraseDialogMode = 2;
|
||||||
|
}
|
||||||
|
QTimer::singleShot(500, this, SLOT(setupPassphraseDialog()));
|
||||||
|
} else {
|
||||||
|
QDir dir("/mnt/onboard/onboard/encfs-dropbox");
|
||||||
|
if (dir.isEmpty()) {
|
||||||
|
ui->activityWidget->setCurrentIndex(4);
|
||||||
|
mkEncfsDirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CryptoManagerWidget::~CryptoManagerWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_setupContinueBtn_clicked() {
|
||||||
|
setupPassphraseDialogMode = 0;
|
||||||
|
setupPassphraseDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::setupPassphraseDialog() {
|
||||||
|
/*
|
||||||
|
* setupPassphraseDialogMode can be:
|
||||||
|
* 0: Initial setup
|
||||||
|
* 1: Normal behavior
|
||||||
|
* 2: Repack
|
||||||
|
*/
|
||||||
|
log("Showing passphrase dialog for mode " + QString::number(setupPassphraseDialogMode), className);
|
||||||
|
ui->activityWidget->hide();
|
||||||
|
this->setStyleSheet("background-color: black");
|
||||||
|
global::keyboard::keyboardDialog = true;
|
||||||
|
global::keyboard::encfsDialog = true;
|
||||||
|
global::keyboard::keyboardText = "";
|
||||||
|
generalDialogWindow = new GeneralDialog();
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
||||||
|
if (setupPassphraseDialogMode == 0) {
|
||||||
|
connect(generalDialogWindow, SIGNAL(destroyed(QObject *)), SLOT(setupEncryptedStorage()));
|
||||||
|
} else if (setupPassphraseDialogMode == 1) {
|
||||||
|
connect(generalDialogWindow, SIGNAL(destroyed(QObject *)), SLOT(unlockEncryptedStorage()));
|
||||||
|
} else {
|
||||||
|
connect(generalDialogWindow, SIGNAL(destroyed(QObject *)), SLOT(repackEncryptedStorage()));
|
||||||
|
}
|
||||||
|
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
|
||||||
|
generalDialogWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_setupAbortBtn_clicked() {
|
||||||
|
log("Aborting setup", className);
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile(".config/18-encrypted_storage/status", "false");
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::quit_restart() {
|
||||||
|
log("Restarting InkBox", className);
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::refreshScreen() {
|
||||||
|
this->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::showToast(QString messageToDisplay) {
|
||||||
|
global::toast::message = messageToDisplay;
|
||||||
|
toastWindow = new toast(this);
|
||||||
|
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(toastWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
||||||
|
toastWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::setupEncryptedStorage() {
|
||||||
|
log("Setting up encrypted storage", className);
|
||||||
|
this->setStyleSheet("background-color: white");
|
||||||
|
ui->activityWidget->show();
|
||||||
|
if (global::encfs::cancelSetup == true) {
|
||||||
|
global::encfs::cancelSetup = false;
|
||||||
|
ui->activityWidget->setCurrentIndex(0);
|
||||||
|
} else {
|
||||||
|
mkEncfsDirs();
|
||||||
|
QString bootstrapPassphrase = global::encfs::passphrase;
|
||||||
|
global::encfs::passphrase = "";
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_create", "true");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_files_location", "/data/onboard/encfs-dropbox");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_archive_location", "/data/onboard/data.encfs");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_bootstrap_passphrase", bootstrapPassphrase);
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile(".config/18-encrypted_storage/storage_list", "/data/onboard/encfs-decrypted");
|
||||||
|
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||||
|
bool exitStatus;
|
||||||
|
ui->activityWidget->setCurrentIndex(3);
|
||||||
|
QTimer *t = new QTimer(this);
|
||||||
|
t->setInterval(1000);
|
||||||
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
|
if (QFile::exists("/external_root/run/encrypted_storage_bootstrap_setup")) {
|
||||||
|
exitStatus = checkconfig("/external_root/run/encrypted_storage_bootstrap_setup");
|
||||||
|
QFile::remove("/external_root/run/encrypted_storage_bootstrap_setup");
|
||||||
|
setupExitWidget(exitStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::unlockEncryptedStorage() {
|
||||||
|
log("Trying to unlock encrypted storage", className);
|
||||||
|
if (global::encfs::cancelSetup == true) {
|
||||||
|
global::encfs::cancelSetup = false;
|
||||||
|
poweroff(true);
|
||||||
|
qApp->quit();
|
||||||
|
} else {
|
||||||
|
this->setStyleSheet("background-color: white");
|
||||||
|
ui->activityWidget->show();
|
||||||
|
mkEncfsDirs();
|
||||||
|
QString passphrase = global::encfs::passphrase;
|
||||||
|
global::encfs::passphrase = "";
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_archive", "/data/onboard/data.encfs");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_mountpoint", "/data/onboard/encfs-decrypted");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_bindmount", "/kobo/mnt/onboard/onboard/encfs-decrypted");
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_passphrase", passphrase);
|
||||||
|
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||||
|
bool exitStatus;
|
||||||
|
|
||||||
|
QString passphraseTriesStr = readFile("/inkbox/encryptedStoragePassphraseTries");
|
||||||
|
if (passphraseTriesStr.isEmpty()) {
|
||||||
|
passphraseTries = 0;
|
||||||
|
} else {
|
||||||
|
passphraseTries = passphraseTriesStr.toInt();
|
||||||
|
passphraseTries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->activityWidget->setCurrentIndex(3);
|
||||||
|
QTimer *t = new QTimer(this);
|
||||||
|
t->setInterval(1000);
|
||||||
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
|
if (QFile::exists("/external_root/run/encfs_mounted")) {
|
||||||
|
exitStatus = true;
|
||||||
|
if (readFile("/external_root/run/encfs_mounted") != "true\n") {
|
||||||
|
exitStatus = false;
|
||||||
|
QFile::remove("/external_root/run/encfs_mounted");
|
||||||
|
QString function = __func__;
|
||||||
|
log(function + ": Invalid passphrase", className);
|
||||||
|
if (setupMessageBoxRan == false) {
|
||||||
|
int delay = 0;
|
||||||
|
if (passphraseTries <= 3) {
|
||||||
|
if (passphraseTries == 0) {
|
||||||
|
writeFile("/inkbox/encryptedStoragePassphraseTries", "0");
|
||||||
|
delay = 5000;
|
||||||
|
} else if (passphraseTries == 1) {
|
||||||
|
writeFile("/inkbox/encryptedStoragePassphraseTries", "1");
|
||||||
|
delay = 10000;
|
||||||
|
} else if (passphraseTries == 2) {
|
||||||
|
writeFile("/inkbox/encryptedStoragePassphraseTries", "2");
|
||||||
|
delay = 20000;
|
||||||
|
} else if (passphraseTries >= 3) {
|
||||||
|
writeFile("/inkbox/encryptedStoragePassphraseTries", "3");
|
||||||
|
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||||
|
currentEpoch += 86400;
|
||||||
|
QString unlockTime_str = QString::number(currentEpoch);
|
||||||
|
global::encfs::unlockTime = QDateTime::fromTime_t(currentEpoch).toString();
|
||||||
|
global::encfs::lockdownMessage = "FATAL: 4 invalid passphrase tries, locking down device until " + global::encfs::unlockTime;
|
||||||
|
writeFile("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str + "\n");
|
||||||
|
global::encfs::lockdown = true;
|
||||||
|
setupMessageBoxRan = true;
|
||||||
|
|
||||||
|
alertWindow = new SplashAlertWidget();
|
||||||
|
alertWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
alertWindow->showFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passphraseTries <= 2) {
|
||||||
|
QTimer::singleShot(delay, this, SLOT(setupFailedAuthenticationMessageBox()));
|
||||||
|
setupMessageBoxRan = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log("Unlocking successful", className);
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::mkEncfsDirs() {
|
||||||
|
log("Creating encrypted storage directories", className);
|
||||||
|
QDir encfsDir;
|
||||||
|
QString encfsPath("/external_root/run/encfs");
|
||||||
|
encfsDir.mkpath(encfsPath);
|
||||||
|
QDir dumpDir;
|
||||||
|
QString dumpPath("/mnt/onboard/onboard/encfs-dropbox");
|
||||||
|
dumpDir.mkpath(dumpPath);
|
||||||
|
QDir decDir;
|
||||||
|
QString decPath("/mnt/onboard/onboard/encfs-decrypted");
|
||||||
|
decDir.mkpath(decPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_exitSuccessBtn_clicked() {
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::setupExitWidget(bool exitStatus) {
|
||||||
|
if (setupExitWidgetRan == false) {
|
||||||
|
if (exitStatus == true) {
|
||||||
|
ui->activityWidget->setCurrentIndex(1);
|
||||||
|
} else {
|
||||||
|
writeFile(".config/18-encrypted_storage/status", "false");
|
||||||
|
ui->activityWidget->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
setupExitWidgetRan = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_failureContinueBtn_clicked() {
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile(".config/18-encrypted_storage/initial_setup_done", "true");
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::setupFailedAuthenticationMessageBox() {
|
||||||
|
log("Showing 'Authentication failed' message box", className);
|
||||||
|
ui->activityWidget->hide();
|
||||||
|
QMessageBox::critical(this, tr("Invalid argument"), tr("<font face='u001'>Invalid passphrase. Please try again.</font>"));
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_acceptBtn_clicked() {
|
||||||
|
writeFile(".config/18-encrypted_storage/status", "false");
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::on_usbmsBtn_clicked() {
|
||||||
|
log("Showing USBMS splash", className);
|
||||||
|
global::usbms::launchUsbms = true;
|
||||||
|
usbmsWindow = new USBMSSplashWidget();
|
||||||
|
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
usbmsWindow->setGeometry(QRect(QPoint(0, 0), screen()->geometry().size()));
|
||||||
|
usbmsWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoManagerWidget::repackEncryptedStorage() {
|
||||||
|
log("Repacking encrypted storage", className);
|
||||||
|
if (global::encfs::cancelSetup == true) {
|
||||||
|
global::encfs::cancelSetup = false;
|
||||||
|
quit_restart();
|
||||||
|
} else {
|
||||||
|
this->setStyleSheet("background-color: white");
|
||||||
|
ui->activityWidget->show();
|
||||||
|
mkEncfsDirs();
|
||||||
|
QString passphrase = global::encfs::passphrase;
|
||||||
|
global::encfs::passphrase = "";
|
||||||
|
writeFile("/external_root/run/encfs/encrypted_storage_repack_passphrase", passphrase);
|
||||||
|
QFile::remove("/external_root/run/openrc/started/encfs");
|
||||||
|
writeFile("/opt/ibxd", "encfs_restart\n");
|
||||||
|
bool exitStatus;
|
||||||
|
ui->activityWidget->setCurrentIndex(3);
|
||||||
|
QTimer *t = new QTimer(this);
|
||||||
|
t->setInterval(1000);
|
||||||
|
connect(t, &QTimer::timeout, [&]() {
|
||||||
|
if (QFile::exists("/external_root/run/encfs_repack_status")) {
|
||||||
|
exitStatus = checkconfig("/external_root/run/encfs_repack_status");
|
||||||
|
QFile::remove("/external_root/run/encfs_repack_status");
|
||||||
|
setupExitWidget(exitStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t->start();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,20 +5,20 @@
|
||||||
#include "generaldialog.h"
|
#include "generaldialog.h"
|
||||||
#include "toast.h"
|
#include "toast.h"
|
||||||
#include "hourglassanimationwidget.h"
|
#include "hourglassanimationwidget.h"
|
||||||
#include "alert.h"
|
#include "splashAlert.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class encryptionManager;
|
class CryptoManagerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class encryptionManager : public QWidget
|
class CryptoManagerWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit encryptionManager(QWidget *parent = nullptr);
|
explicit CryptoManagerWidget(QWidget *parent = nullptr);
|
||||||
~encryptionManager();
|
~CryptoManagerWidget();
|
||||||
bool setupExitWidgetRan = false;
|
bool setupExitWidgetRan = false;
|
||||||
int setupPassphraseDialogMode;
|
int setupPassphraseDialogMode;
|
||||||
bool setupMessageBoxRan = false;
|
bool setupMessageBoxRan = false;
|
||||||
|
@ -43,12 +43,12 @@ private slots:
|
||||||
void repackEncryptedStorage();
|
void repackEncryptedStorage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::encryptionManager *ui;
|
Ui::CryptoManagerWidget *ui;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
|
hourglassAnimationWidget * hourglassAnimationWidgetWindow;
|
||||||
alert * alertWindow;
|
SplashAlertWidget * alertWindow;
|
||||||
usbmsSplash *usbmsWindow;
|
USBMSSplashWidget *usbmsWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENCRYPTIONMANAGER_H
|
#endif // ENCRYPTIONMANAGER_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>encryptionManager</class>
|
<class>CryptoManagerWidget</class>
|
||||||
<widget class="QWidget" name="encryptionManager">
|
<widget class="QWidget" name="CryptoManagerWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
124
src/ui/eink.qrc
Normal file
124
src/ui/eink.qrc
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>../resources/checkbox-checked.png</file>
|
||||||
|
<file>../resources/checkbox-unchecked.png</file>
|
||||||
|
<file>../resources/align-center.png</file>
|
||||||
|
<file>../resources/align-justify.png</file>
|
||||||
|
<file>../resources/align-left.png</file>
|
||||||
|
<file>../resources/align-right.png</file>
|
||||||
|
<file>../resources/chesterton.jpg</file>
|
||||||
|
<file>../resources/alcott.jpg</file>
|
||||||
|
<file>../resources/davies.jpg</file>
|
||||||
|
<file>../resources/king.jpg</file>
|
||||||
|
<file>../resources/star.png</file>
|
||||||
|
<file>../resources/starred_star.png</file>
|
||||||
|
<file>../resources/close.png</file>
|
||||||
|
<file>../resources/chevron-left.png</file>
|
||||||
|
<file>../resources/chevron-right.png</file>
|
||||||
|
<file>../resources/chevron-down.png</file>
|
||||||
|
<file>../resources/chevron-up.png</file>
|
||||||
|
<file>../resources/christie.png</file>
|
||||||
|
<file>../resources/exit.png</file>
|
||||||
|
<file>../resources/usbms.png</file>
|
||||||
|
<file>../resources/settings.png</file>
|
||||||
|
<file>../resources/search.png</file>
|
||||||
|
<file>../resources/power.png</file>
|
||||||
|
<file>../resources/book.png</file>
|
||||||
|
<file>../resources/apps.png</file>
|
||||||
|
<file>../resources/battery_half.png</file>
|
||||||
|
<file>../resources/battery_full.png</file>
|
||||||
|
<file>../resources/battery_empty.png</file>
|
||||||
|
<file>../resources/battery_charging.png</file>
|
||||||
|
<file>../resources/alert.png</file>
|
||||||
|
<file>../resources/eink-dark.qss</file>
|
||||||
|
<file>../resources/frontlight.png</file>
|
||||||
|
<file>../resources/fonts/CrimsonPro-Bold.ttf</file>
|
||||||
|
<file>../resources/fonts/CrimsonPro-Italic.ttf</file>
|
||||||
|
<file>../resources/fonts/CrimsonPro-Regular.ttf</file>
|
||||||
|
<file>../resources/check.png</file>
|
||||||
|
<file>../resources/minus.png</file>
|
||||||
|
<file>../resources/plus.png</file>
|
||||||
|
<file>../resources/battery_alert.png</file>
|
||||||
|
<file>../resources/apps-inverted.png</file>
|
||||||
|
<file>../resources/home.png</file>
|
||||||
|
<file>../resources/settings-inverted.png</file>
|
||||||
|
<file>../resources/kobox-icon.png</file>
|
||||||
|
<file>../resources/X11.png</file>
|
||||||
|
<file>../resources/info.png</file>
|
||||||
|
<file>../resources/nightmode-empty.png</file>
|
||||||
|
<file>../resources/nightmode-full.png</file>
|
||||||
|
<file>../resources/backspace.png</file>
|
||||||
|
<file>../resources/x-circle.png</file>
|
||||||
|
<file>../resources/fonts/Bitter-MediumItalic.ttf</file>
|
||||||
|
<file>../resources/fonts/Bitter-Medium.ttf</file>
|
||||||
|
<file>../resources/fonts/Bitter-Bold.ttf</file>
|
||||||
|
<file>../resources/fonts/Bitter-BoldItalic.ttf</file>
|
||||||
|
<file>../resources/fonts/CrimsonPro-BoldItalic.ttf</file>
|
||||||
|
<file>../resources/fonts/IbarraRealNova-MediumItalic.ttf</file>
|
||||||
|
<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>
|
||||||
|
<file>../resources/zoom-in.png</file>
|
||||||
|
<file>../resources/zoom-out.png</file>
|
||||||
|
<file>../resources/encryption.png</file>
|
||||||
|
<file>../resources/check-display.png</file>
|
||||||
|
<file>../resources/hourglass-bottom.png</file>
|
||||||
|
<file>../resources/hourglass-top.png</file>
|
||||||
|
<file>../resources/error.png</file>
|
||||||
|
<file>../resources/alert-triangle.png</file>
|
||||||
|
<file>../resources/online-library.png</file>
|
||||||
|
<file>../resources/online-library-inverted.png</file>
|
||||||
|
<file>../resources/cover_unavailable.png</file>
|
||||||
|
<file>../resources/clock-inverted.png</file>
|
||||||
|
<file>../resources/clock.png</file>
|
||||||
|
<file>../resources/eink-square-encfs.qss</file>
|
||||||
|
<file>../resources/tzlist</file>
|
||||||
|
<file>../resources/edit.png</file>
|
||||||
|
<file>../resources/save.png</file>
|
||||||
|
<file>../resources/book_inverted.png</file>
|
||||||
|
<file>../resources/arrow-left.png</file>
|
||||||
|
<file>../resources/arrow-right.png</file>
|
||||||
|
<file>../resources/file-text.png</file>
|
||||||
|
<file>../resources/pin.png</file>
|
||||||
|
<file>../resources/highlight.png</file>
|
||||||
|
<file>../resources/unhighlight.png</file>
|
||||||
|
<file>../resources/view-highlights.png</file>
|
||||||
|
<file>../resources/stop.png</file>
|
||||||
|
<file>../resources/refresh.png</file>
|
||||||
|
<file>../resources/hide.png</file>
|
||||||
|
<file>../resources/show.png</file>
|
||||||
|
<file>../resources/christie.jpg</file>
|
||||||
|
<file>../resources/encryption-small.png</file>
|
||||||
|
<file>../resources/lock.png</file>
|
||||||
|
<file>../resources/public.png</file>
|
||||||
|
<file>../resources/wifi-0.png</file>
|
||||||
|
<file>../resources/wifi-25.png</file>
|
||||||
|
<file>../resources/wifi-50.png</file>
|
||||||
|
<file>../resources/wifi-75.png</file>
|
||||||
|
<file>../resources/wifi-100.png</file>
|
||||||
|
<file>../resources/log.png</file>
|
||||||
|
<file>../resources/new.png</file>
|
||||||
|
<file>../resources/checkbox-unchecked-small.png</file>
|
||||||
|
<file>../resources/checkbox-checked-small.png</file>
|
||||||
|
<file>../resources/checkbox-x-small.png</file>
|
||||||
|
<file>../resources/checkbox-x.png</file>
|
||||||
|
<file>../resources/folder.png</file>
|
||||||
|
<file>../resources/question-mark.png</file>
|
||||||
|
<file>../resources/refresh-small.png</file>
|
||||||
|
<file>../resources/checkbox-indeterminate.png</file>
|
||||||
|
<file>../resources/egg/0.jpg</file>
|
||||||
|
<file>../resources/egg/1.jpg</file>
|
||||||
|
<file>../resources/music-note.png</file>
|
||||||
|
<file>../resources/music-library.png</file>
|
||||||
|
<file>../resources/next.png</file>
|
||||||
|
<file>../resources/music-queue.png</file>
|
||||||
|
<file>../resources/play.png</file>
|
||||||
|
<file>../resources/previous.png</file>
|
||||||
|
<file>../resources/pause.png</file>
|
||||||
|
<file>../resources/clean.png</file>
|
||||||
|
<file>../resources/usbms-inverted.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -1,36 +1,52 @@
|
||||||
#include "homepagewidget.h"
|
#include "homepagewidget.h"
|
||||||
#include "ui_homepagewidget.h"
|
#include "ui_homepagewidget.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
homePageWidget::homePageWidget(QWidget *parent) :
|
HomePageWidget::HomePageWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::homePageWidget)
|
ui(new Ui::HomePageWidget)
|
||||||
{
|
{
|
||||||
|
Device * device = Device::getSingleton();
|
||||||
|
Device::ScreenSize screenSize = device->getScreenSize();
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Getting the screen's size
|
// Getting the screen's size
|
||||||
sW = QGuiApplication::screens()[0]->size().width();
|
sW = QGuiApplication::screens()[0]->size().width();
|
||||||
sH = QGuiApplication::screens()[0]->size().height();
|
sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
|
if(screenSize == Device::ScreenSize::SMALL) {
|
||||||
stdIconWidth = sW / 23;
|
stdIconWidth = sW / 23;
|
||||||
stdIconHeight = sH / 23;
|
stdIconHeight = sH / 23;
|
||||||
}
|
bookTitleTruncateThreshold = 20;
|
||||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
stdIconWidthDivider = 8;
|
||||||
stdIconWidth = sW / 25;
|
stdIconHeightDivider = 8;
|
||||||
stdIconHeight = sH / 25;
|
} else if(screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n437\n" or global::deviceID == "n306\n" or global::deviceID == "n249\n" or global::deviceID == "emu\n") {
|
|
||||||
stdIconWidth = sW / 23.5;
|
stdIconWidth = sW / 23.5;
|
||||||
stdIconHeight = sH / 23.5;
|
stdIconHeight = sH / 23.5;
|
||||||
}
|
bookTitleTruncateThreshold = 25;
|
||||||
else {
|
stdIconWidthDivider = 7;
|
||||||
|
stdIconHeightDivider = 7;
|
||||||
|
} else if(screenSize == Device::ScreenSize::LARGE) {
|
||||||
|
stdIconWidth = sW / 24;
|
||||||
|
stdIconHeight = sH / 24;
|
||||||
|
bookTitleTruncateThreshold = 25;
|
||||||
|
stdIconWidthDivider = 6.5;
|
||||||
|
stdIconHeightDivider = 6.5;
|
||||||
|
} else if(screenSize == Device::ScreenSize::VERY_LARGE) {
|
||||||
stdIconWidth = sW / 25;
|
stdIconWidth = sW / 25;
|
||||||
stdIconHeight = sH / 25;
|
stdIconHeight = sH / 25;
|
||||||
|
bookTitleTruncateThreshold = 35;
|
||||||
|
stdIconWidthDivider = 6;
|
||||||
|
stdIconHeightDivider = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ui->recentBooksIconLabel->setPixmap(QPixmap(":/resources/file-text.png").scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
ui->recentBooksIconLabel->setPixmap(QPixmap(":/resources/file-text.png").scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
ui->pinnedBooksIconLabel->setPixmap(QPixmap(":/resources/pin.png").scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
ui->pinnedBooksIconLabel->setPixmap(QPixmap(":/resources/pin.png").scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
|
||||||
|
@ -43,46 +59,8 @@ homePageWidget::homePageWidget(QWidget *parent) :
|
||||||
pinnedBooksBtnArray.resize(global::homePageWidget::pinnedBooksNumber);
|
pinnedBooksBtnArray.resize(global::homePageWidget::pinnedBooksNumber);
|
||||||
pinnedBooksTitleArray.resize(global::homePageWidget::pinnedBooksNumber);
|
pinnedBooksTitleArray.resize(global::homePageWidget::pinnedBooksNumber);
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
bookTitleTruncateThreshold = 20;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
bookTitleTruncateThreshold = 35;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bookTitleTruncateThreshold = 25;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
stdIconWidthDivider = 8;
|
|
||||||
stdIconHeightDivider = 8;
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
stdIconWidth = sW / stdIconWidthDivider;
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
stdIconHeight = sH / stdIconHeightDivider;
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n" or global::deviceID == "emu\n") {
|
|
||||||
stdIconWidthDivider = 7;
|
|
||||||
stdIconHeightDivider = 7;
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n437\n" or global::deviceID == "n249\n") {
|
|
||||||
stdIconWidthDivider = 6.5;
|
|
||||||
stdIconHeightDivider = 6.5;
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n873\n") {
|
|
||||||
stdIconWidthDivider = 6;
|
|
||||||
stdIconHeightDivider = 6;
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stdIconWidthDivider = 8;
|
|
||||||
stdIconHeightDivider = 8;
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!QFile::exists(global::localLibrary::databasePath)) {
|
if(!QFile::exists(global::localLibrary::databasePath)) {
|
||||||
global::toast::modalToast = true;
|
global::toast::modalToast = true;
|
||||||
|
@ -95,12 +73,12 @@ homePageWidget::homePageWidget(QWidget *parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
homePageWidget::~homePageWidget()
|
HomePageWidget::~HomePageWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::openBook(QString bookPath) {
|
void HomePageWidget::openBook(QString bookPath) {
|
||||||
if(!bookPath.isEmpty()) {
|
if(!bookPath.isEmpty()) {
|
||||||
emit openBookSignal(bookPath, false);
|
emit openBookSignal(bookPath, false);
|
||||||
}
|
}
|
||||||
|
@ -109,11 +87,11 @@ void homePageWidget::openBook(QString bookPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::refreshScreenNative() {
|
void HomePageWidget::refreshScreenNative() {
|
||||||
emit refreshScreen();
|
emit refreshScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::setupDisplay(bool databaseGenerated) {
|
void HomePageWidget::setupDisplay(bool databaseGenerated) {
|
||||||
if(databaseGenerated == true) {
|
if(databaseGenerated == true) {
|
||||||
toastWindow->close();
|
toastWindow->close();
|
||||||
}
|
}
|
||||||
|
@ -173,8 +151,8 @@ void homePageWidget::setupDisplay(bool databaseGenerated) {
|
||||||
verticalLayoutArray[i] = new QVBoxLayout();
|
verticalLayoutArray[i] = new QVBoxLayout();
|
||||||
|
|
||||||
// Book icon button
|
// Book icon button
|
||||||
QObject::connect(bookBtnArray[i], &QClickableLabel::bookPath, this, &homePageWidget::openBook);
|
QObject::connect(bookBtnArray[i], &QClickableLabel::bookPath, this, &HomePageWidget::openBook);
|
||||||
QObject::connect(bookBtnArray[i], &QClickableLabel::longPressString, this, &homePageWidget::openBookOptionsDialog);
|
QObject::connect(bookBtnArray[i], &QClickableLabel::longPressString, this, &HomePageWidget::openBookOptionsDialog);
|
||||||
bookBtnArray[i]->setAlignment(Qt::AlignCenter);
|
bookBtnArray[i]->setAlignment(Qt::AlignCenter);
|
||||||
bookBtnArray[i]->setFont(QFont("u001"));
|
bookBtnArray[i]->setFont(QFont("u001"));
|
||||||
bookBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
bookBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
||||||
|
@ -277,8 +255,8 @@ void homePageWidget::setupDisplay(bool databaseGenerated) {
|
||||||
pinnedBooksVerticalLayoutArray[i] = new QVBoxLayout();
|
pinnedBooksVerticalLayoutArray[i] = new QVBoxLayout();
|
||||||
|
|
||||||
// Book icon button
|
// Book icon button
|
||||||
QObject::connect(pinnedBooksBtnArray[i], &QClickableLabel::bookPath, this, &homePageWidget::openBook);
|
QObject::connect(pinnedBooksBtnArray[i], &QClickableLabel::bookPath, this, &HomePageWidget::openBook);
|
||||||
QObject::connect(pinnedBooksBtnArray[i], &QClickableLabel::longPressString, this, &homePageWidget::openBookOptionsDialog);
|
QObject::connect(pinnedBooksBtnArray[i], &QClickableLabel::longPressString, this, &HomePageWidget::openBookOptionsDialog);
|
||||||
pinnedBooksBtnArray[i]->setAlignment(Qt::AlignCenter);
|
pinnedBooksBtnArray[i]->setAlignment(Qt::AlignCenter);
|
||||||
pinnedBooksBtnArray[i]->setFont(QFont("u001"));
|
pinnedBooksBtnArray[i]->setFont(QFont("u001"));
|
||||||
pinnedBooksBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
pinnedBooksBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
||||||
|
@ -355,26 +333,26 @@ void homePageWidget::setupDisplay(bool databaseGenerated) {
|
||||||
QTimer::singleShot(500, this, SLOT(refreshScreenNative()));
|
QTimer::singleShot(500, this, SLOT(refreshScreenNative()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::setupDisplaySlot() {
|
void HomePageWidget::setupDisplaySlot() {
|
||||||
setupDisplay(true);
|
setupDisplay(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::setupDisplayWithDatabase() {
|
void HomePageWidget::setupDisplayWithDatabase() {
|
||||||
global::localLibrary::headless = true;
|
global::localLibrary::headless = true;
|
||||||
localLibraryWidget * localLibraryWidgetWindow = new localLibraryWidget(this);
|
LocalLibraryWidget * localLibraryWidgetWindow = new LocalLibraryWidget(this);
|
||||||
localLibraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
localLibraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
localLibraryWidgetWindow->hide();
|
localLibraryWidgetWindow->hide();
|
||||||
QObject::connect(localLibraryWidgetWindow, &localLibraryWidget::destroyed, this, &homePageWidget::setupDisplaySlot);
|
QObject::connect(localLibraryWidgetWindow, &LocalLibraryWidget::destroyed, this, &HomePageWidget::setupDisplaySlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::showToast(QString messageToDisplay) {
|
void HomePageWidget::showToast(QString messageToDisplay) {
|
||||||
global::toast::message = messageToDisplay;
|
global::toast::message = messageToDisplay;
|
||||||
toastWindow = new toast(this);
|
toastWindow = new toast(this);
|
||||||
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
toastWindow->show();
|
toastWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::openBookOptionsDialog(QString bookPath) {
|
void HomePageWidget::openBookOptionsDialog(QString bookPath) {
|
||||||
int bookID;
|
int bookID;
|
||||||
|
|
||||||
// Finding bookID from bookPath
|
// Finding bookID from bookPath
|
||||||
|
@ -403,23 +381,23 @@ void homePageWidget::openBookOptionsDialog(QString bookPath) {
|
||||||
log("Opening book options dialog for book with path '" + bookPath + "', ID " + QString::number(bookID), className);
|
log("Opening book options dialog for book with path '" + bookPath + "', ID " + QString::number(bookID), className);
|
||||||
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
||||||
global::localLibrary::bookOptionsDialog::deleteOption = false;
|
global::localLibrary::bookOptionsDialog::deleteOption = false;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow = new bookOptionsDialog(this);
|
BookOptionsDialog * bookOptionsDialogWindow = new BookOptionsDialog(this);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &homePageWidget::openLocalBookInfoDialog);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::openLocalBookInfoDialog, this, &HomePageWidget::openLocalBookInfoDialog);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &homePageWidget::showToast);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::showToast, this, &HomePageWidget::showToast);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &homePageWidget::handlePossibleBookPin);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::destroyed, this, &HomePageWidget::handlePossibleBookPin);
|
||||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||||
bookOptionsDialogWindow->show();
|
bookOptionsDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::openLocalBookInfoDialog() {
|
void HomePageWidget::openLocalBookInfoDialog() {
|
||||||
global::bookInfoDialog::localInfoDialog = true;
|
global::bookInfoDialog::localInfoDialog = true;
|
||||||
bookInfoDialog * bookInfoDialogWindow = new bookInfoDialog(this);
|
BookInfoDialog * bookInfoDialogWindow = new BookInfoDialog(this);
|
||||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookInfoDialogWindow->show();
|
bookInfoDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void homePageWidget::handlePossibleBookPin() {
|
void HomePageWidget::handlePossibleBookPin() {
|
||||||
if(global::localLibrary::bookOptionsDialog::bookPinAction == true) {
|
if(global::localLibrary::bookOptionsDialog::bookPinAction == true) {
|
||||||
QTimer::singleShot(3100, this, [&]() {
|
QTimer::singleShot(3100, this, [&]() {
|
||||||
emit relaunchHomePageWidget();
|
emit relaunchHomePageWidget();
|
|
@ -11,17 +11,17 @@
|
||||||
#include "bookinfodialog.h"
|
#include "bookinfodialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class homePageWidget;
|
class HomePageWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class homePageWidget : public QWidget
|
class HomePageWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit homePageWidget(QWidget *parent = nullptr);
|
explicit HomePageWidget(QWidget *parent = nullptr);
|
||||||
~homePageWidget();
|
~HomePageWidget();
|
||||||
int sW;
|
int sW;
|
||||||
int sH;
|
int sH;
|
||||||
int stdIconWidth;
|
int stdIconWidth;
|
||||||
|
@ -48,11 +48,11 @@ private slots:
|
||||||
void handlePossibleBookPin();
|
void handlePossibleBookPin();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::homePageWidget *ui;
|
Ui::HomePageWidget *ui;
|
||||||
localLibraryWidget * localLibraryWidgetWindow;
|
LocalLibraryWidget * localLibraryWidgetWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow;
|
BookOptionsDialog * bookOptionsDialogWindow;
|
||||||
bookInfoDialog * bookInfoDialogWindow;
|
BookInfoDialog * bookInfoDialogWindow;
|
||||||
QVector<QToolTipLabel*> bookTitleArray;
|
QVector<QToolTipLabel*> bookTitleArray;
|
||||||
QVector<QHBoxLayout*> horizontalLayoutArray;
|
QVector<QHBoxLayout*> horizontalLayoutArray;
|
||||||
QVector<QVBoxLayout*> verticalLayoutArray;
|
QVector<QVBoxLayout*> verticalLayoutArray;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>homePageWidget</class>
|
<class>HomePageWidget</class>
|
||||||
<widget class="QWidget" name="homePageWidget">
|
<widget class="QWidget" name="HomePageWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
1032
src/ui/home/mainwindow.cpp
Normal file
1032
src/ui/home/mainwindow.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "quit.h"
|
#include "quit.h"
|
||||||
#include "alert.h"
|
#include "splashAlert.h"
|
||||||
#include "usbmsSplash.h"
|
#include "usbmsSplash.h"
|
||||||
#include "brightnessdialog.h"
|
#include "brightnessdialog.h"
|
||||||
#include "generaldialog.h"
|
#include "generaldialog.h"
|
||||||
|
@ -110,24 +110,24 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow * ui;
|
Ui::MainWindow * ui;
|
||||||
settingsChooser * settingsChooserWindow;
|
SettingsChooserWidget * settingsChooserWindow;
|
||||||
apps * appsWindow;
|
AppsWidget * appsWindow;
|
||||||
reader * readerWindow;
|
ReaderWidget * readerWindow;
|
||||||
quit * quitWindow;
|
QuitWidget * quitWindow;
|
||||||
alert * alertWindow;
|
SplashAlertWidget * alertWindow;
|
||||||
usbmsSplash * usbmsWindow;
|
USBMSSplashWidget * usbmsWindow;
|
||||||
brightnessDialog * brightnessDialogWindow;
|
BrightnessDialog * brightnessDialogWindow;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
koboxSettings * koboxSettingsWindow;
|
KoboxSettingsWidget * koboxSettingsWindow;
|
||||||
koboxAppsDialog * koboxAppsDialogWindow;
|
KoboxAppsDialog * koboxAppsDialogWindow;
|
||||||
textwidget * textwidgetWindow;
|
textwidget * textwidgetWindow;
|
||||||
virtualkeypad * keypadWidget;
|
virtualkeypad * keypadWidget;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
otaManager * otaManagerWindow;
|
OTAUpdateManagerWidget * otaManagerWindow;
|
||||||
libraryWidget * libraryWidgetWindow;
|
LibraryWidget * libraryWidgetWindow;
|
||||||
localLibraryWidget * localLibraryWidgetWindow;
|
LocalLibraryWidget * localLibraryWidgetWindow;
|
||||||
homePageWidget * homePageWidgetWindow;
|
HomePageWidget * homePageWidgetWindow;
|
||||||
telemetry * telemetryInstance;
|
Telemetry * telemetryInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
|
@ -1,17 +1,21 @@
|
||||||
#include "locallibrarywidget.h"
|
#include "locallibrarywidget.h"
|
||||||
#include "ui_locallibrarywidget.h"
|
#include "ui_locallibrarywidget.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
LocalLibraryWidget::LocalLibraryWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::localLibraryWidget)
|
ui(new Ui::LocalLibraryWidget)
|
||||||
{
|
{
|
||||||
|
Device *device = Device::getSingleton();
|
||||||
|
Device::ScreenSize screenSize = device->getScreenSize();
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setFont(QFont("u001"));
|
this->setFont(QFont("u001"));
|
||||||
QObject::connect(ui->pageNumberLabel, &QClickableLabel::clicked, this, &localLibraryWidget::openGoToPageDialog);
|
QObject::connect(ui->pageNumberLabel, &QClickableLabel::clicked, this, &LocalLibraryWidget::openGoToPageDialog);
|
||||||
|
|
||||||
ui->previousPageBtn->setProperty("type", "borderless");
|
ui->previousPageBtn->setProperty("type", "borderless");
|
||||||
ui->previousPageBtn->setEnabled(false);
|
ui->previousPageBtn->setEnabled(false);
|
||||||
|
@ -25,23 +29,23 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
|
|
||||||
ui->goUpBtn->setEnabled(false);
|
ui->goUpBtn->setEnabled(false);
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
if(screenSize == Device::ScreenSize::SMALL) {
|
||||||
buttonsNumber = 3;
|
buttonsNumber = 3;
|
||||||
}
|
}
|
||||||
else if(global::deviceID == "n873\n") {
|
else if(screenSize >= Device::ScreenSize::VERY_LARGE) {
|
||||||
buttonsNumber = 5;
|
buttonsNumber = 5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buttonsNumber = 4;
|
buttonsNumber = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
if(screenSize == Device::ScreenSize::SMALL) {
|
||||||
bookTitleTruncateThreshold = 27;
|
bookTitleTruncateThreshold = 27;
|
||||||
}
|
}
|
||||||
else if(global::deviceID == "n873\n") {
|
else if(screenSize >= Device::ScreenSize::VERY_LARGE) {
|
||||||
bookTitleTruncateThreshold = 45;
|
bookTitleTruncateThreshold = 45;
|
||||||
}
|
}
|
||||||
else if(global::deviceID == "n306\n") {
|
else if(screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
bookTitleTruncateThreshold = 32;
|
bookTitleTruncateThreshold = 32;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -57,34 +61,21 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
sW = QGuiApplication::screens()[0]->size().width();
|
sW = QGuiApplication::screens()[0]->size().width();
|
||||||
sH = QGuiApplication::screens()[0]->size().height();
|
sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
|
||||||
|
if(screenSize == Device::ScreenSize::SMALL) {
|
||||||
stdIconWidthDivider = 7.2;
|
stdIconWidthDivider = 7.2;
|
||||||
stdIconHeightDivider = 7.2;
|
stdIconHeightDivider = 7.2;
|
||||||
}
|
} else if(screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
else if(global::deviceID == "n905\n" or global::deviceID == "kt\n") {
|
|
||||||
stdIconWidthDivider = 9.5;
|
|
||||||
stdIconHeightDivider = 9.5;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n613\n" or global::deviceID == "emu\n") {
|
|
||||||
stdIconWidthDivider = 8.7;
|
|
||||||
stdIconHeightDivider = 8.7;
|
|
||||||
}
|
|
||||||
else if(global::deviceID == "n437\n" or global::deviceID == "n249\n") {
|
|
||||||
stdIconWidthDivider = 8.1;
|
stdIconWidthDivider = 8.1;
|
||||||
stdIconHeightDivider = 8.1;
|
stdIconHeightDivider = 8.1;
|
||||||
}
|
} else if(screenSize == Device::ScreenSize::LARGE) {
|
||||||
else if(global::deviceID == "n873\n") {
|
stdIconWidthDivider = 8.5;
|
||||||
|
stdIconHeightDivider = 8.5;
|
||||||
|
} else if(screenSize >= Device::ScreenSize::VERY_LARGE) {
|
||||||
stdIconWidthDivider = 9.7;
|
stdIconWidthDivider = 9.7;
|
||||||
stdIconHeightDivider = 9.7;
|
stdIconHeightDivider = 9.7;
|
||||||
}
|
}
|
||||||
else if(global::deviceID == "n236\n" or global::deviceID == "n306\n") {
|
|
||||||
stdIconWidthDivider = 9.1;
|
|
||||||
stdIconHeightDivider = 9.1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stdIconWidthDivider = 9.5;
|
|
||||||
stdIconHeightDivider = 9.5;
|
|
||||||
}
|
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
stdIconWidth = sW / stdIconWidthDivider;
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
stdIconHeight = sH / stdIconHeightDivider;
|
||||||
|
|
||||||
|
@ -109,12 +100,12 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localLibraryWidget::~localLibraryWidget()
|
LocalLibraryWidget::~LocalLibraryWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupDatabase() {
|
void LocalLibraryWidget::setupDatabase() {
|
||||||
setDefaultWorkDir();
|
setDefaultWorkDir();
|
||||||
if(!QFile::exists(global::localLibrary::databasePath)) {
|
if(!QFile::exists(global::localLibrary::databasePath)) {
|
||||||
log("Generating database", className);
|
log("Generating database", className);
|
||||||
|
@ -195,11 +186,11 @@ void localLibraryWidget::setupDatabase() {
|
||||||
|
|
||||||
if(global::localLibrary::headless == true) {
|
if(global::localLibrary::headless == true) {
|
||||||
global::localLibrary::headless = false;
|
global::localLibrary::headless = false;
|
||||||
localLibraryWidget::close();
|
LocalLibraryWidget::close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupBooksList(int pageNumber) {
|
void LocalLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
idList.clear();
|
idList.clear();
|
||||||
int in = 1;
|
int in = 1;
|
||||||
for(int i = (1 * pageNumber * buttonsNumber) - (buttonsNumber - 1); i <= (1 * pageNumber * buttonsNumber); i++) {
|
for(int i = (1 * pageNumber * buttonsNumber) - (buttonsNumber - 1); i <= (1 * pageNumber * buttonsNumber); i++) {
|
||||||
|
@ -279,7 +270,7 @@ void localLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::on_previousPageBtn_clicked()
|
void LocalLibraryWidget::on_previousPageBtn_clicked()
|
||||||
{
|
{
|
||||||
log("Previous button clicked", className);
|
log("Previous button clicked", className);
|
||||||
|
|
||||||
|
@ -303,7 +294,7 @@ void localLibraryWidget::on_previousPageBtn_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void localLibraryWidget::on_nextPageBtn_clicked()
|
void LocalLibraryWidget::on_nextPageBtn_clicked()
|
||||||
{
|
{
|
||||||
currentPageNumber++;
|
currentPageNumber++;
|
||||||
setupBooksListToggle(currentPageNumber);
|
setupBooksListToggle(currentPageNumber);
|
||||||
|
@ -315,14 +306,14 @@ void localLibraryWidget::on_nextPageBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBook(int bookID) {
|
void LocalLibraryWidget::openBook(int bookID) {
|
||||||
QJsonObject jsonObject = databaseJsonArrayList.at(bookID - 1).toObject();
|
QJsonObject jsonObject = databaseJsonArrayList.at(bookID - 1).toObject();
|
||||||
QString bookPath = jsonObject["BookPath"].toString();
|
QString bookPath = jsonObject["BookPath"].toString();
|
||||||
log("Opening book with ID " + QString::number(bookID) + ", path '" + bookPath + "'", className);
|
log("Opening book with ID " + QString::number(bookID) + ", path '" + bookPath + "'", className);
|
||||||
emit openBookSignal(bookPath, false);
|
emit openBookSignal(bookPath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
void LocalLibraryWidget::btnOpenBook(int buttonNumber) {
|
||||||
log("Book/directory button clicked, buttonNumber is " + QString::number(buttonNumber), className);
|
log("Book/directory button clicked, buttonNumber is " + QString::number(buttonNumber), className);
|
||||||
if(mainPathIsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
|
@ -339,23 +330,23 @@ void localLibraryWidget::btnOpenBook(int buttonNumber) {
|
||||||
else {
|
else {
|
||||||
log("A book was selected", className);
|
log("A book was selected", className);
|
||||||
openBook(id);
|
openBook(id);
|
||||||
localLibraryWidget::close();
|
LocalLibraryWidget::close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openGoToPageDialog() {
|
void LocalLibraryWidget::openGoToPageDialog() {
|
||||||
if(mainPathIsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Showing 'Go to page' dialog", className);
|
log("Showing 'Go to page' dialog", className);
|
||||||
global::keyboard::keypadDialog = true;
|
global::keyboard::keypadDialog = true;
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new GeneralDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QObject::connect(generalDialogWindow, &generalDialog::gotoPageSelected, this, &localLibraryWidget::goToPage);
|
QObject::connect(generalDialogWindow, &GeneralDialog::gotoPageSelected, this, &LocalLibraryWidget::goToPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::goToPage(int page) {
|
void LocalLibraryWidget::goToPage(int page) {
|
||||||
checkIfMainPathIsEmpty();
|
checkIfMainPathIsEmpty();
|
||||||
if(mainPathIsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
|
@ -375,11 +366,11 @@ void localLibraryWidget::goToPage(int page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::refreshScreenNative() {
|
void LocalLibraryWidget::refreshScreenNative() {
|
||||||
emit refreshScreen();
|
emit refreshScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupDisplay() {
|
void LocalLibraryWidget::setupDisplay() {
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
if(noBooksInDatabase == false) {
|
if(noBooksInDatabase == false) {
|
||||||
// Prevent segmentation fault if a book was the last of its page
|
// Prevent segmentation fault if a book was the last of its page
|
||||||
|
@ -403,14 +394,14 @@ void localLibraryWidget::setupDisplay() {
|
||||||
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::showToast(QString messageToDisplay) {
|
void LocalLibraryWidget::showToast(QString messageToDisplay) {
|
||||||
global::toast::message = messageToDisplay;
|
global::toast::message = messageToDisplay;
|
||||||
toastWindow = new toast(this);
|
toastWindow = new toast(this);
|
||||||
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
toastWindow->show();
|
toastWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
void LocalLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
if(mainPathIsEmpty == true) {
|
if(mainPathIsEmpty == true) {
|
||||||
return void();
|
return void();
|
||||||
}
|
}
|
||||||
|
@ -440,17 +431,17 @@ void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
log("Opening book options dialog for book with pseudo-ID " + QString::number(pseudoBookID) + ", ID " + QString::number(bookID), className);
|
log("Opening book options dialog for book with pseudo-ID " + QString::number(pseudoBookID) + ", ID " + QString::number(bookID), className);
|
||||||
// Here, ID should go because of idList.at(pseudoBookID - 1);
|
// Here, ID should go because of idList.at(pseudoBookID - 1);
|
||||||
global::localLibrary::bookOptionsDialog::bookID = id;
|
global::localLibrary::bookOptionsDialog::bookID = id;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow = new bookOptionsDialog(this);
|
BookOptionsDialog * bookOptionsDialogWindow = new BookOptionsDialog(this);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::openLocalBookInfoDialog, this, &LocalLibraryWidget::openLocalBookInfoDialog);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &localLibraryWidget::showToast);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::showToast, this, &LocalLibraryWidget::showToast);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::destroyed, this, &LocalLibraryWidget::handlePossibleBookDeletion);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::removedFolder, this, &localLibraryWidget::refreshFolders);
|
QObject::connect(bookOptionsDialogWindow, &BookOptionsDialog::removedFolder, this, &LocalLibraryWidget::refreshFolders);
|
||||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||||
bookOptionsDialogWindow->show();
|
bookOptionsDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::handlePossibleBookDeletion() {
|
void LocalLibraryWidget::handlePossibleBookDeletion() {
|
||||||
if(global::localLibrary::bookOptionsDialog::bookDeleted == true) {
|
if(global::localLibrary::bookOptionsDialog::bookDeleted == true) {
|
||||||
QTimer::singleShot(3100, this, [&]() {
|
QTimer::singleShot(3100, this, [&]() {
|
||||||
global::toast::modalToast = true;
|
global::toast::modalToast = true;
|
||||||
|
@ -461,14 +452,14 @@ void localLibraryWidget::handlePossibleBookDeletion() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openLocalBookInfoDialog() {
|
void LocalLibraryWidget::openLocalBookInfoDialog() {
|
||||||
global::bookInfoDialog::localInfoDialog = true;
|
global::bookInfoDialog::localInfoDialog = true;
|
||||||
bookInfoDialog * bookInfoDialogWindow = new bookInfoDialog(this);
|
BookInfoDialog * bookInfoDialogWindow = new BookInfoDialog(this);
|
||||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookInfoDialogWindow->show();
|
bookInfoDialogWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupBooksListToggle(int pageNumber) {
|
void LocalLibraryWidget::setupBooksListToggle(int pageNumber) {
|
||||||
if(folderFeatureEnabled == true) {
|
if(folderFeatureEnabled == true) {
|
||||||
setupBooksListFolders(pageNumber);
|
setupBooksListFolders(pageNumber);
|
||||||
}
|
}
|
||||||
|
@ -477,7 +468,7 @@ void localLibraryWidget::setupBooksListToggle(int pageNumber) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
void LocalLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
log("Showing folders for page: " + QString::number(pageNumber), className);
|
log("Showing folders for page: " + QString::number(pageNumber), className);
|
||||||
QStringList directoryList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
QStringList directoryList = QDir(pathForFolders).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||||
log("Full directory list is '" + directoryList.join(", ") + "'", className);
|
log("Full directory list is '" + directoryList.join(", ") + "'", className);
|
||||||
|
@ -644,7 +635,7 @@ void localLibraryWidget::setupBooksListFolders(int pageNumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets pagesNumber for folders feature, and everything else
|
// Sets pagesNumber for folders feature, and everything else
|
||||||
void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
void LocalLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
||||||
log("Main path is '" + pathForFolders + "'", className);
|
log("Main path is '" + pathForFolders + "'", className);
|
||||||
|
|
||||||
checkIfMainPathIsEmpty();
|
checkIfMainPathIsEmpty();
|
||||||
|
@ -713,7 +704,7 @@ void localLibraryWidget::calculateMaximumPagesNumberForFolders() {
|
||||||
// Sorting the vector if needed should be done here
|
// Sorting the vector if needed should be done here
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::calculateIndexForPage(int pageNumber) {
|
void LocalLibraryWidget::calculateIndexForPage(int pageNumber) {
|
||||||
if(pageNumber == firstPageForBooks + 1) {
|
if(pageNumber == firstPageForBooks + 1) {
|
||||||
log("Variable firstPageForBooks is 0", className);
|
log("Variable firstPageForBooks is 0", className);
|
||||||
bookIndexVector = 0;
|
bookIndexVector = 0;
|
||||||
|
@ -747,7 +738,7 @@ void localLibraryWidget::calculateIndexForPage(int pageNumber) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::changePathAndRefresh(QString directory) {
|
void LocalLibraryWidget::changePathAndRefresh(QString directory) {
|
||||||
log("Changing path", className);
|
log("Changing path", className);
|
||||||
QString temporaryPathForFolders = pathForFolders + directory + "/";
|
QString temporaryPathForFolders = pathForFolders + directory + "/";
|
||||||
if(QDir(temporaryPathForFolders).isEmpty() == false) {
|
if(QDir(temporaryPathForFolders).isEmpty() == false) {
|
||||||
|
@ -762,12 +753,12 @@ void localLibraryWidget::changePathAndRefresh(QString directory) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::on_goUpBtn_clicked()
|
void LocalLibraryWidget::on_goUpBtn_clicked()
|
||||||
{
|
{
|
||||||
goUpFunction();
|
goUpFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::goUpFunction() {
|
void LocalLibraryWidget::goUpFunction() {
|
||||||
if(pathForFolders != "/mnt/onboard/onboard/") {
|
if(pathForFolders != "/mnt/onboard/onboard/") {
|
||||||
log("Changing path; going back", className);
|
log("Changing path; going back", className);
|
||||||
// This can't be a one-liner
|
// This can't be a one-liner
|
||||||
|
@ -786,7 +777,7 @@ void localLibraryWidget::goUpFunction() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::on_pathBtn_clicked()
|
void LocalLibraryWidget::on_pathBtn_clicked()
|
||||||
{
|
{
|
||||||
log("Showing path dialog", className);
|
log("Showing path dialog", className);
|
||||||
QString pathForFoldersSaved = pathForFolders;
|
QString pathForFoldersSaved = pathForFolders;
|
||||||
|
@ -794,14 +785,14 @@ void localLibraryWidget::on_pathBtn_clicked()
|
||||||
pathForFolders = pathForFoldersSaved;
|
pathForFolders = pathForFoldersSaved;
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::refreshFolders() {
|
void LocalLibraryWidget::refreshFolders() {
|
||||||
log("Called refresh folders");
|
log("Called refresh folders");
|
||||||
calculateMaximumPagesNumberForFolders();
|
calculateMaximumPagesNumberForFolders();
|
||||||
bookIndexVector = 0;
|
bookIndexVector = 0;
|
||||||
goToPage(1);
|
goToPage(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::checkIfMainPathIsEmpty() {
|
void LocalLibraryWidget::checkIfMainPathIsEmpty() {
|
||||||
if(folderFeatureEnabled == true) {
|
if(folderFeatureEnabled == true) {
|
||||||
// If the main path is empty, prevent it from freezing and using the CPU at 100% because of a while loop
|
// If the main path is empty, prevent it from freezing and using the CPU at 100% because of a while loop
|
||||||
if(pathForFolders == "/mnt/onboard/onboard/") {
|
if(pathForFolders == "/mnt/onboard/onboard/") {
|
||||||
|
@ -827,8 +818,8 @@ void localLibraryWidget::checkIfMainPathIsEmpty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupButtonsLook() {
|
void LocalLibraryWidget::setupButtonsLook() {
|
||||||
for(int i = 1; i <= buttonsNumber; i++) {
|
for(int i = 0; i < buttonsNumber; i++) {
|
||||||
// Horizontal layout that will contain the book button and its icon
|
// Horizontal layout that will contain the book button and its icon
|
||||||
horizontalLayoutArray[i] = new QHBoxLayout(this);
|
horizontalLayoutArray[i] = new QHBoxLayout(this);
|
||||||
|
|
||||||
|
@ -839,8 +830,8 @@ void localLibraryWidget::setupButtonsLook() {
|
||||||
// Book button
|
// Book button
|
||||||
bookBtnArray[i] = new QClickableLabel(this);
|
bookBtnArray[i] = new QClickableLabel(this);
|
||||||
bookBtnArray[i]->setObjectName(QString::number(i));
|
bookBtnArray[i]->setObjectName(QString::number(i));
|
||||||
QObject::connect(bookBtnArray[i], &QClickableLabel::bookID, this, &localLibraryWidget::btnOpenBook);
|
QObject::connect(bookBtnArray[i], &QClickableLabel::bookID, this, &LocalLibraryWidget::btnOpenBook);
|
||||||
QObject::connect(bookBtnArray[i], &QClickableLabel::longPressInt, this, &localLibraryWidget::openBookOptionsDialog);
|
QObject::connect(bookBtnArray[i], &QClickableLabel::longPressInt, this, &LocalLibraryWidget::openBookOptionsDialog);
|
||||||
bookBtnArray[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
bookBtnArray[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
bookBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
bookBtnArray[i]->setStyleSheet("color: black; background-color: white; border-radius: 10px; padding: 10px");
|
||||||
bookBtnArray[i]->setFont(QFont("u001"));
|
bookBtnArray[i]->setFont(QFont("u001"));
|
||||||
|
@ -860,7 +851,7 @@ void localLibraryWidget::setupButtonsLook() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::cleanButtons() {
|
void LocalLibraryWidget::cleanButtons() {
|
||||||
log("Hiding items", className);
|
log("Hiding items", className);
|
||||||
for(int i = 1; i <= buttonsNumber; i++) {
|
for(int i = 1; i <= buttonsNumber; i++) {
|
||||||
if(bookIconArray[i]->isHidden() == false) {
|
if(bookIconArray[i]->isHidden() == false) {
|
|
@ -13,17 +13,17 @@
|
||||||
#include "bookinfodialog.h"
|
#include "bookinfodialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class localLibraryWidget;
|
class LocalLibraryWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class localLibraryWidget : public QWidget
|
class LocalLibraryWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit localLibraryWidget(QWidget *parent = nullptr);
|
explicit LocalLibraryWidget(QWidget *parent = nullptr);
|
||||||
~localLibraryWidget();
|
~LocalLibraryWidget();
|
||||||
int buttonsNumber;
|
int buttonsNumber;
|
||||||
int sW;
|
int sW;
|
||||||
int sH;
|
int sH;
|
||||||
|
@ -87,11 +87,11 @@ private slots:
|
||||||
void on_pathBtn_clicked();
|
void on_pathBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::localLibraryWidget * ui;
|
Ui::LocalLibraryWidget * ui;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow;
|
BookOptionsDialog * bookOptionsDialogWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
bookInfoDialog * bookInfoDialogWindow;
|
BookInfoDialog * bookInfoDialogWindow;
|
||||||
QVector<QHBoxLayout*> horizontalLayoutArray;
|
QVector<QHBoxLayout*> horizontalLayoutArray;
|
||||||
QVector<QLabel*> bookIconArray;
|
QVector<QLabel*> bookIconArray;
|
||||||
QVector<QClickableLabel*> bookBtnArray;
|
QVector<QClickableLabel*> bookBtnArray;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>localLibraryWidget</class>
|
<class>LocalLibraryWidget</class>
|
||||||
<widget class="QWidget" name="localLibraryWidget">
|
<widget class="QWidget" name="LocalLibraryWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
|
@ -1,6 +1,7 @@
|
||||||
#include "librarywidget.h"
|
#include "librarywidget.h"
|
||||||
#include "ui_librarywidget.h"
|
#include "ui_librarywidget.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -8,10 +9,11 @@
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
|
||||||
libraryWidget::libraryWidget(QWidget *parent) :
|
LibraryWidget::LibraryWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::libraryWidget)
|
ui(new Ui::LibraryWidget)
|
||||||
{
|
{
|
||||||
|
Device* device = Device::getSingleton();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->booksStackedWidget->hide();
|
ui->booksStackedWidget->hide();
|
||||||
|
|
||||||
|
@ -34,7 +36,9 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
||||||
}
|
}
|
||||||
QFont crimson(family);
|
QFont crimson(family);
|
||||||
|
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
|
||||||
|
|
||||||
|
if(device->getScreenSize() <= Device::ScreenSize::MEDIUM) {
|
||||||
ui->previousBtn->setText("");
|
ui->previousBtn->setText("");
|
||||||
ui->previousBtn->setProperty("type", "borderless");
|
ui->previousBtn->setProperty("type", "borderless");
|
||||||
ui->nextBtn->setText("");
|
ui->nextBtn->setText("");
|
||||||
|
@ -70,7 +74,7 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
||||||
ui->book6Btn->setProperty("type", "borderless");
|
ui->book6Btn->setProperty("type", "borderless");
|
||||||
ui->book7Btn->setProperty("type", "borderless");
|
ui->book7Btn->setProperty("type", "borderless");
|
||||||
ui->book8Btn->setProperty("type", "borderless");
|
ui->book8Btn->setProperty("type", "borderless");
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
if(device->getScreenSize() > Device::ScreenSize::MEDIUM) {
|
||||||
ui->book9Btn->setText("");
|
ui->book9Btn->setText("");
|
||||||
ui->book10Btn->setText("");
|
ui->book10Btn->setText("");
|
||||||
ui->book11Btn->setText("");
|
ui->book11Btn->setText("");
|
||||||
|
@ -114,7 +118,7 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
||||||
ui->book6Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book6Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
ui->book7Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book7Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
ui->book8Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book8Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
if(device->getScreenSize() > Device::ScreenSize::MEDIUM) {
|
||||||
ui->book9Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book9Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
ui->book10Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book10Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
ui->book11Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
ui->book11Label->setStyleSheet("font-size: 8.5pt; font-style: italic");
|
||||||
|
@ -150,7 +154,7 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
||||||
ui->book6Label->setFont(crimson);
|
ui->book6Label->setFont(crimson);
|
||||||
ui->book7Label->setFont(crimson);
|
ui->book7Label->setFont(crimson);
|
||||||
ui->book8Label->setFont(crimson);
|
ui->book8Label->setFont(crimson);
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
if(device->getScreenSize() > Device::ScreenSize::MEDIUM) {
|
||||||
ui->book9Label->setFont(crimson);
|
ui->book9Label->setFont(crimson);
|
||||||
ui->book10Label->setFont(crimson);
|
ui->book10Label->setFont(crimson);
|
||||||
ui->book11Label->setFont(crimson);
|
ui->book11Label->setFont(crimson);
|
||||||
|
@ -183,15 +187,16 @@ libraryWidget::libraryWidget(QWidget *parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryWidget::~libraryWidget()
|
LibraryWidget::~LibraryWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::setupView() {
|
void LibraryWidget::setupView() {
|
||||||
|
Device *device = Device::getSingleton();
|
||||||
ui->booksStackedWidget->show();
|
ui->booksStackedWidget->show();
|
||||||
|
|
||||||
if(global::deviceID == "n705\n") {
|
if(device->getScreenSize() == Device::ScreenSize::SMALL) {
|
||||||
stdIconWidth = sW / 7
|
stdIconWidth = sW / 7
|
||||||
;
|
;
|
||||||
stdIconHeight = sH / 7;
|
stdIconHeight = sH / 7;
|
||||||
|
@ -209,7 +214,7 @@ void libraryWidget::setupView() {
|
||||||
ui->book6Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/6/title"));
|
ui->book6Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/6/title"));
|
||||||
ui->book7Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/7/title"));
|
ui->book7Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/7/title"));
|
||||||
ui->book8Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/8/title"));
|
ui->book8Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/8/title"));
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
if(device->getScreenSize() > Device::ScreenSize::MEDIUM) {
|
||||||
ui->book9Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/9/title"));
|
ui->book9Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/9/title"));
|
||||||
ui->book10Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/10/title"));
|
ui->book10Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/10/title"));
|
||||||
ui->book11Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/11/title"));
|
ui->book11Label->setText(readFile("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/11/title"));
|
||||||
|
@ -236,7 +241,7 @@ void libraryWidget::setupView() {
|
||||||
ui->book7Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
ui->book7Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
||||||
ui->book8Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/8/cover.jpg"));
|
ui->book8Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/8/cover.jpg"));
|
||||||
ui->book8Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
ui->book8Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
||||||
if(global::deviceID != "n705\n" and global::deviceID != "n905\n" and global::deviceID != "kt\n") {
|
if(device->getScreenSize() > Device::ScreenSize::MEDIUM) {
|
||||||
ui->book9Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/9/cover.jpg"));
|
ui->book9Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/9/cover.jpg"));
|
||||||
ui->book9Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
ui->book9Btn->setIconSize(QSize(stdIconWidth, stdIconHeight));
|
||||||
ui->book10Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/10/cover.jpg"));
|
ui->book10Btn->setIcon(QIcon("/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/10/cover.jpg"));
|
||||||
|
@ -256,19 +261,19 @@ void libraryWidget::setupView() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::showToast(QString messageToDisplay) {
|
void LibraryWidget::showToast(QString messageToDisplay) {
|
||||||
global::toast::message = messageToDisplay;
|
global::toast::message = messageToDisplay;
|
||||||
toastWindow = new toast(this);
|
toastWindow = new toast(this);
|
||||||
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
toastWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
toastWindow->show();
|
toastWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::closeIndefiniteToast() {
|
void LibraryWidget::closeIndefiniteToast() {
|
||||||
// Warning: use with caution
|
// Warning: use with caution
|
||||||
toastWindow->close();
|
toastWindow->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::syncCatalog() {
|
void LibraryWidget::syncCatalog() {
|
||||||
global::toast::modalToast = true;
|
global::toast::modalToast = true;
|
||||||
global::toast::indefiniteToast = true;
|
global::toast::indefiniteToast = true;
|
||||||
log("Gutenberg sync in progress", className);
|
log("Gutenberg sync in progress", className);
|
||||||
|
@ -276,7 +281,7 @@ void libraryWidget::syncCatalog() {
|
||||||
QTimer::singleShot(500, this, SLOT(syncCatalogSlot()));
|
QTimer::singleShot(500, this, SLOT(syncCatalogSlot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::syncCatalogSlot() {
|
void LibraryWidget::syncCatalogSlot() {
|
||||||
bool syncDone = false;
|
bool syncDone = false;
|
||||||
writeFile("/opt/ibxd", "gutenberg_sync\n");
|
writeFile("/opt/ibxd", "gutenberg_sync\n");
|
||||||
while(true) {
|
while(true) {
|
||||||
|
@ -301,20 +306,20 @@ void libraryWidget::syncCatalogSlot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::on_previousBtn_clicked()
|
void LibraryWidget::on_previousBtn_clicked()
|
||||||
{
|
{
|
||||||
ui->booksStackedWidget->setCurrentIndex(0);
|
ui->booksStackedWidget->setCurrentIndex(0);
|
||||||
ui->pageLabel->setText("1 <i>of</i> 2");
|
ui->pageLabel->setText("1 <i>of</i> 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_nextBtn_clicked()
|
void LibraryWidget::on_nextBtn_clicked()
|
||||||
{
|
{
|
||||||
ui->booksStackedWidget->setCurrentIndex(1);
|
ui->booksStackedWidget->setCurrentIndex(1);
|
||||||
ui->pageLabel->setText("2 <i>of</i> 2");
|
ui->pageLabel->setText("2 <i>of</i> 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString libraryWidget::getTitle(int bookNumber) {
|
QString LibraryWidget::getTitle(int bookNumber) {
|
||||||
QString bookNumberQstr = QString::number(bookNumber);
|
QString bookNumberQstr = QString::number(bookNumber);
|
||||||
QString fullTitlePath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
QString fullTitlePath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||||
fullTitlePath = fullTitlePath.append(bookNumberQstr);
|
fullTitlePath = fullTitlePath.append(bookNumberQstr);
|
||||||
|
@ -323,7 +328,7 @@ QString libraryWidget::getTitle(int bookNumber) {
|
||||||
return readFile(fullTitlePath);
|
return readFile(fullTitlePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
|
void LibraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
|
||||||
QString idPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
QString idPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||||
idPath = idPath.append(bookNumber);
|
idPath = idPath.append(bookNumber);
|
||||||
idPath = idPath.append("/id");
|
idPath = idPath.append("/id");
|
||||||
|
@ -332,7 +337,7 @@ void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
|
||||||
global::library::latestBookNumber = bookNumber;
|
global::library::latestBookNumber = bookNumber;
|
||||||
global::library::bookTitle = title;
|
global::library::bookTitle = title;
|
||||||
|
|
||||||
bookInfoDialogWindow = new bookInfoDialog(this);
|
bookInfoDialogWindow = new BookInfoDialog(this);
|
||||||
connect(bookInfoDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
|
connect(bookInfoDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
|
||||||
connect(bookInfoDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
connect(bookInfoDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
||||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -341,111 +346,111 @@ void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book1Btn_clicked()
|
void LibraryWidget::on_book1Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(1);
|
QString title = getTitle(1);
|
||||||
openLatestBookInfoDialog(1, title);
|
openLatestBookInfoDialog(1, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::on_book2Btn_clicked()
|
void LibraryWidget::on_book2Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(2);
|
QString title = getTitle(2);
|
||||||
openLatestBookInfoDialog(2, title);
|
openLatestBookInfoDialog(2, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book3Btn_clicked()
|
void LibraryWidget::on_book3Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(3);
|
QString title = getTitle(3);
|
||||||
openLatestBookInfoDialog(3, title);
|
openLatestBookInfoDialog(3, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book4Btn_clicked()
|
void LibraryWidget::on_book4Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(4);
|
QString title = getTitle(4);
|
||||||
openLatestBookInfoDialog(4, title);
|
openLatestBookInfoDialog(4, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book5Btn_clicked()
|
void LibraryWidget::on_book5Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(5);
|
QString title = getTitle(5);
|
||||||
openLatestBookInfoDialog(5, title);
|
openLatestBookInfoDialog(5, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book6Btn_clicked()
|
void LibraryWidget::on_book6Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(6);
|
QString title = getTitle(6);
|
||||||
openLatestBookInfoDialog(6, title);
|
openLatestBookInfoDialog(6, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book7Btn_clicked()
|
void LibraryWidget::on_book7Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(7);
|
QString title = getTitle(7);
|
||||||
openLatestBookInfoDialog(7, title);
|
openLatestBookInfoDialog(7, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book8Btn_clicked()
|
void LibraryWidget::on_book8Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(8);
|
QString title = getTitle(8);
|
||||||
openLatestBookInfoDialog(8, title);
|
openLatestBookInfoDialog(8, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book9Btn_clicked()
|
void LibraryWidget::on_book9Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(9);
|
QString title = getTitle(9);
|
||||||
openLatestBookInfoDialog(9, title);
|
openLatestBookInfoDialog(9, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book10Btn_clicked()
|
void LibraryWidget::on_book10Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(10);
|
QString title = getTitle(10);
|
||||||
openLatestBookInfoDialog(10, title);
|
openLatestBookInfoDialog(10, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book11Btn_clicked()
|
void LibraryWidget::on_book11Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(11);
|
QString title = getTitle(11);
|
||||||
openLatestBookInfoDialog(11, title);
|
openLatestBookInfoDialog(11, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book12Btn_clicked()
|
void LibraryWidget::on_book12Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(12);
|
QString title = getTitle(12);
|
||||||
openLatestBookInfoDialog(12, title);
|
openLatestBookInfoDialog(12, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book13Btn_clicked()
|
void LibraryWidget::on_book13Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(13);
|
QString title = getTitle(13);
|
||||||
openLatestBookInfoDialog(13, title);
|
openLatestBookInfoDialog(13, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book14Btn_clicked()
|
void LibraryWidget::on_book14Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(14);
|
QString title = getTitle(14);
|
||||||
openLatestBookInfoDialog(14, title);
|
openLatestBookInfoDialog(14, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book15Btn_clicked()
|
void LibraryWidget::on_book15Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(15);
|
QString title = getTitle(15);
|
||||||
openLatestBookInfoDialog(15, title);
|
openLatestBookInfoDialog(15, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void libraryWidget::on_book16Btn_clicked()
|
void LibraryWidget::on_book16Btn_clicked()
|
||||||
{
|
{
|
||||||
QString title = getTitle(16);
|
QString title = getTitle(16);
|
||||||
openLatestBookInfoDialog(16, title);
|
openLatestBookInfoDialog(16, title);
|
|
@ -6,26 +6,26 @@
|
||||||
#include <bookinfodialog.h>
|
#include <bookinfodialog.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class libraryWidget;
|
class LibraryWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class libraryWidget : public QWidget
|
class LibraryWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit libraryWidget(QWidget *parent = nullptr);
|
explicit LibraryWidget(QWidget *parent = nullptr);
|
||||||
~libraryWidget();
|
~LibraryWidget();
|
||||||
float sH;
|
float sH;
|
||||||
float sW;
|
float sW;
|
||||||
float stdIconHeight;
|
float stdIconHeight;
|
||||||
float stdIconWidth;
|
float stdIconWidth;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::libraryWidget * ui;
|
Ui::LibraryWidget * ui;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
bookInfoDialog * bookInfoDialogWindow;
|
BookInfoDialog * bookInfoDialogWindow;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void syncCatalog();
|
void syncCatalog();
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>libraryWidget</class>
|
<class>LibraryWidget</class>
|
||||||
<widget class="QWidget" name="libraryWidget">
|
<widget class="QWidget" name="LibraryWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
|
@ -6,9 +6,9 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
otaManager::otaManager(QWidget *parent) :
|
OTAUpdateManagerWidget::OTAUpdateManagerWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::otaManager)
|
ui(new Ui::OTAUpdateManagerWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
|
@ -30,7 +30,7 @@ otaManager::otaManager(QWidget *parent) :
|
||||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||||
writeFile("/external_root/opt/storage/update/last_sync", QString::number(currentEpoch));
|
writeFile("/external_root/opt/storage/update/last_sync", QString::number(currentEpoch));
|
||||||
QFile::remove("/run/can_ota_update");
|
QFile::remove("/run/can_ota_update");
|
||||||
otaManager::close();
|
OTAUpdateManagerWidget::close();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
otaCheckTimer->start();
|
otaCheckTimer->start();
|
||||||
|
@ -54,14 +54,14 @@ otaManager::otaManager(QWidget *parent) :
|
||||||
global::otaUpdate::downloadOta = false;
|
global::otaUpdate::downloadOta = false;
|
||||||
}
|
}
|
||||||
QFile::remove("/external_root/opt/storage/update/last_sync");
|
QFile::remove("/external_root/opt/storage/update/last_sync");
|
||||||
otaManager::close();
|
OTAUpdateManagerWidget::close();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
otaDownloadTimer->start();
|
otaDownloadTimer->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otaManager::~otaManager()
|
OTAUpdateManagerWidget::~OTAUpdateManagerWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
|
@ -4,20 +4,20 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class otaManager;
|
class OTAUpdateManagerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class otaManager : public QWidget
|
class OTAUpdateManagerWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit otaManager(QWidget *parent = nullptr);
|
explicit OTAUpdateManagerWidget(QWidget *parent = nullptr);
|
||||||
~otaManager();
|
~OTAUpdateManagerWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::otaManager *ui;
|
Ui::OTAUpdateManagerWidget *ui;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void canOtaUpdate(bool yesno);
|
void canOtaUpdate(bool yesno);
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>otaManager</class>
|
<class>OTAUpdateManagerWidget</class>
|
||||||
<widget class="QWidget" name="otaManager">
|
<widget class="QWidget" name="OTAUpdateManagerWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
89
src/ui/quit/quit.cpp
Normal file
89
src/ui/quit/quit.cpp
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#include "quit.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_quit.h"
|
||||||
|
#include <linux/input.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
QuitWidget::QuitWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::QuitWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->backBtn->setFont(QFont("u001"));
|
||||||
|
|
||||||
|
ui->pushButton->setProperty("type", "borderless");
|
||||||
|
ui->pushButton_2->setProperty("type", "borderless");
|
||||||
|
ui->pushButton_3->setProperty("type", "borderless");
|
||||||
|
ui->pushButton_4->setProperty("type", "borderless");
|
||||||
|
ui->backBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
// Getting the screen's size
|
||||||
|
float sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
float sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
// Defining what the "Quit" icon size will be
|
||||||
|
float stdIconWidth = sW / 1.25;
|
||||||
|
float stdIconHeight = sH / 1.25;
|
||||||
|
|
||||||
|
QPixmap pixmap(":/resources/exit.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->label->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
||||||
|
ui->pushButton_3->setText("Deep suspend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QuitWidget::~QuitWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuitWidget::on_pushButton_clicked() {
|
||||||
|
// Prevent strange "appearing from nowhere" low battery or critical battery alerts due to sysfs unmount
|
||||||
|
global::battery::showCriticalBatteryAlert = false;
|
||||||
|
global::battery::showLowBatteryDialog = false;
|
||||||
|
|
||||||
|
// GUI apps
|
||||||
|
updateUserAppsMainJsonFile();
|
||||||
|
|
||||||
|
poweroff(true);
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuitWidget::on_pushButton_2_clicked() {
|
||||||
|
global::battery::showCriticalBatteryAlert = false;
|
||||||
|
global::battery::showLowBatteryDialog = false;
|
||||||
|
|
||||||
|
// GUI apps
|
||||||
|
updateUserAppsMainJsonFile();
|
||||||
|
|
||||||
|
reboot(true);
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuitWidget::on_pushButton_4_clicked() {
|
||||||
|
log("Restarting InkBox", className);
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuitWidget::on_backBtn_clicked() {
|
||||||
|
QuitWidget::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuitWidget::on_pushButton_3_clicked() {
|
||||||
|
log("Suspending", className);
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
||||||
|
writeFile("/dev/ipd/sleepCall", "deepSleep");
|
||||||
|
} else {
|
||||||
|
writeFile("/dev/ipd/sleepCall", "sleep");
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,17 +6,17 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class quit;
|
class QuitWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class quit : public QWidget
|
class QuitWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit quit(QWidget *parent = nullptr);
|
explicit QuitWidget(QWidget *parent = nullptr);
|
||||||
~quit();
|
~QuitWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
|
@ -26,7 +26,7 @@ private slots:
|
||||||
void on_pushButton_3_clicked();
|
void on_pushButton_3_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::quit *ui;
|
Ui::QuitWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUIT_H
|
#endif // QUIT_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>quit</class>
|
<class>QuitWidget</class>
|
||||||
<widget class="QWidget" name="quit">
|
<widget class="QWidget" name="QuitWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
2115
src/ui/reader/reader.cpp
Normal file
2115
src/ui/reader/reader.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
||||||
#define READER_H
|
#define READER_H
|
||||||
|
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "alert.h"
|
#include "splashAlert.h"
|
||||||
#include "generaldialog.h"
|
#include "generaldialog.h"
|
||||||
#include "toast.h"
|
#include "toast.h"
|
||||||
#include "quit.h"
|
#include "quit.h"
|
||||||
|
@ -41,17 +41,17 @@ namespace mupdf {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class reader;
|
class ReaderWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class reader : public QWidget
|
class ReaderWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit reader(QWidget *parent = nullptr);
|
explicit ReaderWidget(QWidget *parent = nullptr);
|
||||||
~reader();
|
~ReaderWidget();
|
||||||
|
|
||||||
int split_total;
|
int split_total;
|
||||||
int split_files_number;
|
int split_files_number;
|
||||||
|
@ -174,15 +174,15 @@ signals:
|
||||||
void openBookFile(QString book, bool relativePath);
|
void openBookFile(QString book, bool relativePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::reader * ui;
|
Ui::ReaderWidget * ui;
|
||||||
alert * alertWindow;
|
SplashAlertWidget * alertWindow;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
quit * quitWindow;
|
QuitWidget * quitWindow;
|
||||||
textDialog * textDialogWindow;
|
TextDialog * textDialogWindow;
|
||||||
highlightsListDialog * highlightsListDialogWindow;
|
HighlightsListDialog * highlightsListDialogWindow;
|
||||||
QGraphicsScene * graphicsScene;
|
QGraphicsScene * graphicsScene;
|
||||||
brightnessDialog * brightnessDialogWindow;
|
BrightnessDialog * brightnessDialogWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // READER_H
|
#endif // READER_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>reader</class>
|
<class>ReaderWidget</class>
|
||||||
<widget class="QWidget" name="reader">
|
<widget class="QWidget" name="ReaderWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
110
src/ui/settings/koboxsettings.cpp
Normal file
110
src/ui/settings/koboxsettings.cpp
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
#include "koboxsettings.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_koboxsettings.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
KoboxSettingsWidget::KoboxSettingsWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::KoboxSettingsWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
KoboxSettingsWidget::setFont(QFont("u001"));
|
||||||
|
ui->okBtn->setFont(QFont("Inter"));
|
||||||
|
|
||||||
|
// UI tweaks
|
||||||
|
ui->okBtn->setProperty("type", "borderless");
|
||||||
|
ui->pushButton->setProperty("type", "borderless");
|
||||||
|
ui->resetKoboxBtn->setProperty("type", "borderless");
|
||||||
|
ui->pushButton->setStyleSheet("font-weight: bold");
|
||||||
|
ui->resetKoboxBtn->setStyleSheet("font-weight: bold");
|
||||||
|
ui->okBtn->setStyleSheet("font-weight: bold");
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
if (checkconfig("/external_root/boot/flags/X11_START") == true) {
|
||||||
|
ui->koboxStatusLabel->setText("KoBox is <b>enabled</b>");
|
||||||
|
not_user_change = true;
|
||||||
|
ui->checkBox->click();
|
||||||
|
ui->runtimeSettingsWidget->setVisible(true);
|
||||||
|
} else {
|
||||||
|
ui->koboxStatusLabel->setText("KoBox is <b>disabled</b>");
|
||||||
|
ui->runtimeSettingsWidget->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DPI setting
|
||||||
|
QString dpiSetting;
|
||||||
|
QString dpiSettingStr = readFile(".config/00-kobox/dpiSetting");
|
||||||
|
int dpi = dpiSettingStr.toInt();
|
||||||
|
if (dpiSettingStr.isEmpty()) {
|
||||||
|
dpi = Device::getSingleton()->getSingleton()->getBaseDPI();
|
||||||
|
writeFile(".config/00-kobox/dpiSetting", QString(dpi));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->spinBox->setValue(dpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
KoboxSettingsWidget::~KoboxSettingsWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::on_okBtn_clicked() {
|
||||||
|
KoboxSettingsWidget::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::on_checkBox_toggled(bool checked) {
|
||||||
|
if (checked == true) {
|
||||||
|
if (not_user_change != true) {
|
||||||
|
log("Enabling KoBox subsystem", className);
|
||||||
|
writeFile("/external_root/boot/flags/X11_START", "true\n");
|
||||||
|
openSettingsRebootDialog();
|
||||||
|
} else {
|
||||||
|
not_user_change = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log("Disabling KoBox subsystem", className);
|
||||||
|
writeFile("/external_root/boot/flags/X11_START", "false\n");
|
||||||
|
openSettingsRebootDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::openSettingsRebootDialog() {
|
||||||
|
log("Showing reboot dialog", className);
|
||||||
|
global::settings::settingsRebootDialog = true;
|
||||||
|
global::kobox::koboxSettingsRebootDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
void KoboxSettingsWidget::openResetKoboxDialog() {
|
||||||
|
log("Showing KoBox reset dialog", className);
|
||||||
|
global::kobox::resetKoboxDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::on_spinBox_valueChanged(int arg1) {
|
||||||
|
QString number = QString::number(arg1);
|
||||||
|
writeFile(".config/00-kobox/dpiSetting", number);
|
||||||
|
log("X11 DPI set to " + number, className);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::on_pushButton_clicked() {
|
||||||
|
// Export Extensions disk image over USB with g_mass_storage/g_file_storage
|
||||||
|
global::usbms::usbmsDialog = false;
|
||||||
|
global::usbms::launchUsbms = true;
|
||||||
|
global::usbms::koboxExportExtensions = true;
|
||||||
|
|
||||||
|
log("Exporting KoBox extensions onboard storage via USB", className);
|
||||||
|
log("Showing USBMS splash", className);
|
||||||
|
usbmsWindow = new USBMSSplashWidget();
|
||||||
|
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
usbmsWindow->setGeometry(QRect(QPoint(0, 0), screen()->geometry().size()));
|
||||||
|
usbmsWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KoboxSettingsWidget::on_resetKoboxBtn_clicked() {
|
||||||
|
openResetKoboxDialog();
|
||||||
|
}
|
|
@ -7,17 +7,17 @@
|
||||||
#include "usbmsSplash.h"
|
#include "usbmsSplash.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class koboxSettings;
|
class KoboxSettingsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class koboxSettings : public QWidget
|
class KoboxSettingsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit koboxSettings(QWidget *parent = nullptr);
|
explicit KoboxSettingsWidget(QWidget *parent = nullptr);
|
||||||
~koboxSettings();
|
~KoboxSettingsWidget();
|
||||||
|
|
||||||
bool not_user_change = false;
|
bool not_user_change = false;
|
||||||
void openSettingsRebootDialog();
|
void openSettingsRebootDialog();
|
||||||
|
@ -31,9 +31,9 @@ private slots:
|
||||||
void on_resetKoboxBtn_clicked();
|
void on_resetKoboxBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::koboxSettings *ui;
|
Ui::KoboxSettingsWidget *ui;
|
||||||
generalDialog *generalDialogWindow;
|
GeneralDialog *generalDialogWindow;
|
||||||
usbmsSplash *usbmsWindow;
|
USBMSSplashWidget *usbmsWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KOBOXSETTINGS_H
|
#endif // KOBOXSETTINGS_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>koboxSettings</class>
|
<class>KoboxSettingsWidget</class>
|
||||||
<widget class="QWidget" name="koboxSettings">
|
<widget class="QWidget" name="KoboxSettingsWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
399
src/ui/settings/powerdaemonsettings.cpp
Normal file
399
src/ui/settings/powerdaemonsettings.cpp
Normal file
|
@ -0,0 +1,399 @@
|
||||||
|
#include "powerdaemonsettings.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "ui_powerdaemonsettings.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
PowerDaemonSettingsWidget::PowerDaemonSettingsWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::PowerDaemonSettingsWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
PowerDaemonSettingsWidget::setFont(QFont("u001"));
|
||||||
|
ui->mainLabel->setFont(QFont("Inter"));
|
||||||
|
|
||||||
|
// Avoid some display issues (label moving because width of text would change with a proportional font)
|
||||||
|
ui->CBSLabel->setFont(QFont("Roboto Mono"));
|
||||||
|
ui->idleSleepLabel->setFont(QFont("Roboto Mono"));
|
||||||
|
|
||||||
|
// Font tweaks
|
||||||
|
ui->label_2->setFont(QFont("Inter"));
|
||||||
|
ui->exitBtn->setFont(QFont("Inter"));
|
||||||
|
|
||||||
|
// UI tweaks
|
||||||
|
ui->exitBtn->setProperty("type", "borderless");
|
||||||
|
ui->expBtn->setProperty("type", "borderless");
|
||||||
|
ui->hWhenChargerSleepBtn->setProperty("type", "borderless");
|
||||||
|
ui->hChargerWakeUpBtn->setProperty("type", "borderless");
|
||||||
|
ui->wifiReconnectBtn->setProperty("type", "borderless");
|
||||||
|
ui->ledUsageBtn->setProperty("type", "borderless");
|
||||||
|
ui->hCustomCaseBtn->setProperty("type", "borderless");
|
||||||
|
ui->deepSleepBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
ui->mainLabel->setStyleSheet("font-weight: bold");
|
||||||
|
ui->CBSLabel->setStyleSheet("font-weight: bold");
|
||||||
|
ui->idleSleepLabel->setStyleSheet("font-weight: bold");
|
||||||
|
ui->exitBtn->setStyleSheet("font-weight: bold");
|
||||||
|
// Experimental features label
|
||||||
|
ui->label_2->setStyleSheet("font-weight: bold");
|
||||||
|
|
||||||
|
Device::ScreenSize screenSize = Device::getSingleton()->getScreenSize();
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
int controlBtnFixedWidth;
|
||||||
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
|
controlBtnFixedWidth = 50;
|
||||||
|
} else {
|
||||||
|
controlBtnFixedWidth = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->CBSDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
|
||||||
|
ui->CBSDecreaseBtn->setFixedWidth(controlBtnFixedWidth);
|
||||||
|
ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
|
||||||
|
ui->CBSIncreaseBtn->setFixedWidth(controlBtnFixedWidth);
|
||||||
|
|
||||||
|
int idleBtnsFixedWidth;
|
||||||
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
|
idleBtnsFixedWidth = 80;
|
||||||
|
} else {
|
||||||
|
idleBtnsFixedWidth = 100;
|
||||||
|
}
|
||||||
|
ui->idleSleepDecreaseBtn->setFixedWidth(idleBtnsFixedWidth);
|
||||||
|
ui->idleSleepIncreaseBtn->setFixedWidth(idleBtnsFixedWidth);
|
||||||
|
ui->idleSleepDecreaseMBtn->setFixedWidth(idleBtnsFixedWidth);
|
||||||
|
ui->idleSleepIncreaseMBtn->setFixedWidth(idleBtnsFixedWidth);
|
||||||
|
|
||||||
|
// Padding
|
||||||
|
ui->CBSDecreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt");
|
||||||
|
ui->CBSIncreaseBtn->setStyleSheet("padding: 10px; font-size: 10pt");
|
||||||
|
ui->idleSleepDecreaseBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
||||||
|
ui->idleSleepIncreaseBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
||||||
|
ui->idleSleepDecreaseMBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
||||||
|
ui->idleSleepIncreaseMBtn->setStyleSheet("font-family: 'Roboto Mono'; font-weight: bold; padding: 10px; font-size: 10pt");
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
// Button tweaks
|
||||||
|
int autoRepeatDelay = 1250;
|
||||||
|
int autoRepeatInterval = 20;
|
||||||
|
|
||||||
|
ui->CBSDecreaseBtn->setAutoRepeat(true);
|
||||||
|
ui->CBSDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->CBSDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
ui->CBSIncreaseBtn->setAutoRepeat(true);
|
||||||
|
ui->CBSIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->CBSIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
ui->idleSleepDecreaseBtn->setAutoRepeat(true);
|
||||||
|
ui->idleSleepDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->idleSleepDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
ui->idleSleepIncreaseBtn->setAutoRepeat(true);
|
||||||
|
ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->idleSleepIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
ui->idleSleepDecreaseMBtn->setAutoRepeat(true);
|
||||||
|
ui->idleSleepDecreaseMBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->idleSleepDecreaseMBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
ui->idleSleepIncreaseMBtn->setAutoRepeat(true);
|
||||||
|
ui->idleSleepIncreaseMBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||||
|
ui->idleSleepIncreaseMBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||||
|
|
||||||
|
// Hide items
|
||||||
|
ui->hLabel_3->hide();
|
||||||
|
ui->hCpuFreqComboBox->hide();
|
||||||
|
|
||||||
|
ui->hWhenChargerSleepBtn->hide();
|
||||||
|
ui->hChargerWakeUpBtn->hide();
|
||||||
|
ui->hCustomCaseBtn->hide();
|
||||||
|
|
||||||
|
// Prepare variables from system configuration (20-sleep_daemon)
|
||||||
|
log("Reading variables from power daemon configuration", className);
|
||||||
|
|
||||||
|
// 1 - cinematicBrightnessDelayMs
|
||||||
|
QString cinematicBrightnessMs = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs");
|
||||||
|
|
||||||
|
cinematicBrightnessInt = cinematicBrightnessMs.toInt();
|
||||||
|
convertCinematicInt();
|
||||||
|
|
||||||
|
// 2 - cpuGovernor
|
||||||
|
QString cpuGovernor = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor");
|
||||||
|
|
||||||
|
QStringList cpuGovernorList = QStringList{ cpuGovernor };
|
||||||
|
if (cpuGovernorList.contains("interactive") == false) {
|
||||||
|
cpuGovernorList.append("interactive");
|
||||||
|
}
|
||||||
|
if (cpuGovernorList.contains("conservative") == false) {
|
||||||
|
cpuGovernorList.append("conservative");
|
||||||
|
}
|
||||||
|
if (cpuGovernorList.contains("userspace") == false) {
|
||||||
|
cpuGovernorList.append("userspace");
|
||||||
|
}
|
||||||
|
if (cpuGovernorList.contains("powersave") == false) {
|
||||||
|
cpuGovernorList.append("powersave");
|
||||||
|
}
|
||||||
|
if (cpuGovernorList.contains("ondemand") == false) {
|
||||||
|
cpuGovernorList.append("ondemand");
|
||||||
|
}
|
||||||
|
if (cpuGovernorList.contains("performance") == false) {
|
||||||
|
cpuGovernorList.append("performance");
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->hCpuFreqComboBox->addItems(cpuGovernorList);
|
||||||
|
ui->hCpuFreqComboBox->setCurrentIndex(0);
|
||||||
|
|
||||||
|
// 3 - whenChargerSleep
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep") == true) {
|
||||||
|
whenChargerSleepBool = true;
|
||||||
|
ui->hWhenChargerSleepBtn->click();
|
||||||
|
} else {
|
||||||
|
whenChargerSleepBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4 - chargerWakeUp
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp") == true) {
|
||||||
|
chargerWakeUpBool = true;
|
||||||
|
ui->hChargerWakeUpBtn->click();
|
||||||
|
} else {
|
||||||
|
chargerWakeUpBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5 - wifiReconnect
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect") == true) {
|
||||||
|
ui->wifiReconnectBtn->click();
|
||||||
|
wifiReconnectBool = true;
|
||||||
|
} else {
|
||||||
|
wifiReconnectBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6 - ledUsage
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage") == true) {
|
||||||
|
ui->ledUsageBtn->click();
|
||||||
|
ledUsageBool = true;
|
||||||
|
} else {
|
||||||
|
ledUsageBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7 - idleSleep
|
||||||
|
QString idleSleepString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/7-idleSleep");
|
||||||
|
idleSleepInt = idleSleepString.replace("\n", "").toInt();
|
||||||
|
convertIdleSleepInt();
|
||||||
|
|
||||||
|
// 8 - customCase
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase") == true) {
|
||||||
|
ui->hCustomCaseBtn->click();
|
||||||
|
customCaseBool = true;
|
||||||
|
} else {
|
||||||
|
customCaseBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 9 - deepSleep
|
||||||
|
if (checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
||||||
|
ui->deepSleepBtn->click();
|
||||||
|
deepSleepBool = true;
|
||||||
|
} else {
|
||||||
|
deepSleepBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PowerDaemonSettingsWidget::~PowerDaemonSettingsWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_CBSIncreaseBtn_clicked() {
|
||||||
|
if (cinematicBrightnessInt < 500) {
|
||||||
|
cinematicBrightnessInt = cinematicBrightnessInt + 1;
|
||||||
|
convertCinematicInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_CBSDecreaseBtn_clicked() {
|
||||||
|
if (cinematicBrightnessInt != 0) {
|
||||||
|
cinematicBrightnessInt = cinematicBrightnessInt - 1;
|
||||||
|
convertCinematicInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_exitBtn_clicked() {
|
||||||
|
// Save all to files
|
||||||
|
// 1 - cinematicBrightnessdelayMs
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs", QString::number(cinematicBrightnessInt));
|
||||||
|
// 2 - cpuGovernor
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor", ui->hCpuFreqComboBox->currentText());
|
||||||
|
// 3 - whenChargerSleep
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep", QVariant(whenChargerSleepBool).toString());
|
||||||
|
// 4 - chargerWakeUp
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp", QVariant(chargerWakeUpBool).toString());
|
||||||
|
// 5 - wifiReconnect
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect", QVariant(wifiReconnectBool).toString());
|
||||||
|
// 6 - ledUsage
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage", QVariant(ledUsageBool).toString());
|
||||||
|
// 7 - idleSleep
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/7-idleSleep", QString::number(idleSleepInt));
|
||||||
|
// 8 - customCase
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase", QVariant(customCaseBool).toString());
|
||||||
|
// 9 - deepSleep
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep", QVariant(deepSleepBool).toString());
|
||||||
|
|
||||||
|
// Notify power daemon of configuration update
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/updateConfig", "true");
|
||||||
|
|
||||||
|
PowerDaemonSettingsWidget::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_expBtn_clicked() {
|
||||||
|
// TODO: Implement additional warning
|
||||||
|
ui->hLabel_3->show();
|
||||||
|
ui->hCpuFreqComboBox->show();
|
||||||
|
|
||||||
|
ui->hWhenChargerSleepBtn->show();
|
||||||
|
ui->hChargerWakeUpBtn->show();
|
||||||
|
ui->hCustomCaseBtn->show();
|
||||||
|
|
||||||
|
ui->expBtn->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_hWhenChargerSleepBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "suspend when charging";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
whenChargerSleepBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
whenChargerSleepBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_hChargerWakeUpBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "ignore charger wake-up events";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
chargerWakeUpBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
chargerWakeUpBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_wifiReconnectBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "Wi-Fi reconnection on wake-up";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
wifiReconnectBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
wifiReconnectBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_ledUsageBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "use LED";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
ledUsageBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
ledUsageBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_idleSleepIncreaseBtn_clicked() {
|
||||||
|
if (idleSleepInt >= 15) {
|
||||||
|
idleSleepInt = idleSleepInt + 1;
|
||||||
|
} else {
|
||||||
|
idleSleepInt = 15;
|
||||||
|
}
|
||||||
|
convertIdleSleepInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_idleSleepDecreaseBtn_clicked() {
|
||||||
|
if (idleSleepInt >= 15) {
|
||||||
|
idleSleepInt = idleSleepInt - 1;
|
||||||
|
if (idleSleepInt == 14) {
|
||||||
|
idleSleepInt = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idleSleepInt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
convertIdleSleepInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::convertIdleSleepInt() {
|
||||||
|
int copiedIdleSleepInt = idleSleepInt;
|
||||||
|
int minutes = 0;
|
||||||
|
int seconds = 0;
|
||||||
|
if (copiedIdleSleepInt == 0) {
|
||||||
|
ui->idleSleepLabel->setText("Never");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (copiedIdleSleepInt >= 60) {
|
||||||
|
minutes = minutes + 1;
|
||||||
|
copiedIdleSleepInt = copiedIdleSleepInt - 60;
|
||||||
|
}
|
||||||
|
seconds = copiedIdleSleepInt;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
if (minutes != 0) {
|
||||||
|
text.append(QString::number(minutes) + "m");
|
||||||
|
}
|
||||||
|
if (seconds != 0) {
|
||||||
|
text.append(" ");
|
||||||
|
text.append(QString::number(seconds) + "s");
|
||||||
|
}
|
||||||
|
ui->idleSleepLabel->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_hCustomCaseBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "custom case";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
customCaseBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
customCaseBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_deepSleepBtn_clicked(bool checked) {
|
||||||
|
QString settingString = "deep sleep";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
deepSleepBool = true;
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
deepSleepBool = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::convertCinematicInt() {
|
||||||
|
QString text = QString::number(cinematicBrightnessInt);
|
||||||
|
// To avoid moving other widgets when the value changes
|
||||||
|
text.append(" ms");
|
||||||
|
ui->CBSLabel->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_idleSleepIncreaseMBtn_clicked() {
|
||||||
|
if (idleSleepInt >= 15) {
|
||||||
|
idleSleepInt = idleSleepInt + 60;
|
||||||
|
} else {
|
||||||
|
idleSleepInt = 60;
|
||||||
|
}
|
||||||
|
convertIdleSleepInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerDaemonSettingsWidget::on_idleSleepDecreaseMBtn_clicked() {
|
||||||
|
if (idleSleepInt >= 60) {
|
||||||
|
idleSleepInt = idleSleepInt - 60;
|
||||||
|
if (idleSleepInt < 14) {
|
||||||
|
idleSleepInt = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idleSleepInt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
convertIdleSleepInt();
|
||||||
|
}
|
|
@ -4,17 +4,17 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class powerDaemonSettings;
|
class PowerDaemonSettingsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class powerDaemonSettings : public QWidget
|
class PowerDaemonSettingsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit powerDaemonSettings(QWidget *parent = nullptr);
|
explicit PowerDaemonSettingsWidget(QWidget *parent = nullptr);
|
||||||
~powerDaemonSettings();
|
~PowerDaemonSettingsWidget();
|
||||||
int cinematicBrightnessMs;
|
int cinematicBrightnessMs;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -39,7 +39,7 @@ private slots:
|
||||||
void on_idleSleepDecreaseMBtn_clicked();
|
void on_idleSleepDecreaseMBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::powerDaemonSettings * ui;
|
Ui::PowerDaemonSettingsWidget * ui;
|
||||||
bool whenChargerSleepBool;
|
bool whenChargerSleepBool;
|
||||||
bool chargerWakeUpBool;
|
bool chargerWakeUpBool;
|
||||||
bool wifiReconnectBool;
|
bool wifiReconnectBool;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>powerDaemonSettings</class>
|
<class>PowerDaemonSettingsWidget</class>
|
||||||
<widget class="QWidget" name="powerDaemonSettings">
|
<widget class="QWidget" name="PowerDaemonSettingsWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
944
src/ui/settings/settings.cpp
Normal file
944
src/ui/settings/settings.cpp
Normal file
|
@ -0,0 +1,944 @@
|
||||||
|
#include "settings.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
#include "ui_settings.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
SettingsWidget::SettingsWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::SettingsWidget) {
|
||||||
|
Device *device = Device::getSingleton();
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
|
SettingsWidget::setFont(QFont("u001"));
|
||||||
|
ui->comboBox->setFont(QFont("u001"));
|
||||||
|
ui->tzComboBox->setFont(QFont("u001"));
|
||||||
|
ui->aboutBtn->setFont(QFont("u001"));
|
||||||
|
ui->headerBtn->setFont(QFont("Inter"));
|
||||||
|
ui->headerLabel->setFont(QFont("Chivo"));
|
||||||
|
ui->readingSettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->homeSettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->librarySettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->storageSettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->systemSettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->securitySettingsBtn->setFont(QFont("Chivo"));
|
||||||
|
ui->okBtn->setFont(QFont("Inter"));
|
||||||
|
|
||||||
|
ui->setPasscodeBtn->setProperty("type", "borderless");
|
||||||
|
ui->okBtn->setProperty("type", "borderless");
|
||||||
|
ui->aboutBtn->setProperty("type", "borderless");
|
||||||
|
ui->requestLeaseBtn->setProperty("type", "borderless");
|
||||||
|
ui->usbmsBtn->setProperty("type", "borderless");
|
||||||
|
ui->updateBtn->setProperty("type", "borderless");
|
||||||
|
ui->resetBtn->setProperty("type", "borderless");
|
||||||
|
ui->showSystemInfoBtn->setProperty("type", "borderless");
|
||||||
|
ui->generateSystemReportBtn->setProperty("type", "borderless");
|
||||||
|
ui->checkOtaUpdateBtn->setProperty("type", "borderless");
|
||||||
|
ui->repackBtn->setProperty("type", "borderless");
|
||||||
|
ui->exportHighlightsBtn->setProperty("type", "borderless");
|
||||||
|
ui->label->setStyleSheet("font-size: 10.5pt; font-weight: bold");
|
||||||
|
ui->okBtn->setStyleSheet("font-weight: bold");
|
||||||
|
ui->aboutBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->requestLeaseBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->usbmsBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->updateBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->resetBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->showSystemInfoBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->generateSystemReportBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->checkOtaUpdateBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->comboBox->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->tzComboBox->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->setPasscodeBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->repackBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->exportHighlightsBtn->setStyleSheet("font-size: 9pt");
|
||||||
|
|
||||||
|
// Getting the screen's size
|
||||||
|
sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
|
||||||
|
// Defining what the default icon size will be
|
||||||
|
if (device->getScreenSize() == Device::ScreenSize::SMALL) {
|
||||||
|
homeIconWidth = sW / 18;
|
||||||
|
homeIconHeight = sW / 18;
|
||||||
|
} else {
|
||||||
|
homeIconWidth = sW / 20;
|
||||||
|
homeIconHeight = sW / 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->headerStackedWidget->hide();
|
||||||
|
|
||||||
|
ui->headerBtn->setIcon(QIcon(":/resources/chevron-left.png"));
|
||||||
|
ui->headerBtn->setProperty("type", "borderless");
|
||||||
|
ui->headerBtn->setStyleSheet("font-size: 9pt; font-weight: bold; padding: 15px");
|
||||||
|
ui->headerLabel->setStyleSheet("padding: 15px");
|
||||||
|
|
||||||
|
ui->readingSettingsBtn->setText("\t\t\tReading");
|
||||||
|
ui->readingSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->readingSettingsBtn->setStyleSheet("padding: 25px; Text-align: left");
|
||||||
|
ui->readingSettingsBtn->setIcon(QIcon(":/resources/book.png"));
|
||||||
|
ui->readingSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->homeSettingsBtn->setText("\t\t\tHome");
|
||||||
|
ui->homeSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->homeSettingsBtn->setStyleSheet("padding: 25px; Text-align:left");
|
||||||
|
ui->homeSettingsBtn->setIcon(QIcon(":/resources/home.png"));
|
||||||
|
ui->homeSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->librarySettingsBtn->setText("\t\t\t Library");
|
||||||
|
ui->librarySettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->librarySettingsBtn->setStyleSheet("padding: 25px; Text-align:left");
|
||||||
|
ui->librarySettingsBtn->setIcon(QIcon(":/resources/online-library.png"));
|
||||||
|
ui->storageSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->storageSettingsBtn->setText("\t\t\tStorage");
|
||||||
|
ui->storageSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->storageSettingsBtn->setStyleSheet("padding: 25px; Text-align:left");
|
||||||
|
ui->storageSettingsBtn->setIcon(QIcon(":/resources/usbms-inverted.png"));
|
||||||
|
ui->storageSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->systemSettingsBtn->setText("\t\t\tSystem");
|
||||||
|
ui->systemSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->systemSettingsBtn->setStyleSheet("padding: 25px; Text-align:left");
|
||||||
|
ui->systemSettingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||||
|
ui->systemSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->securitySettingsBtn->setText("\t\t\tSecurity");
|
||||||
|
ui->securitySettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->securitySettingsBtn->setStyleSheet("padding: 25px; Text-align:left");
|
||||||
|
ui->securitySettingsBtn->setIcon(QIcon(":/resources/lock.png"));
|
||||||
|
ui->securitySettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
|
||||||
|
ui->usbNetworkingCheckBox->hide();
|
||||||
|
ui->requestLeaseBtn->hide();
|
||||||
|
ui->usbmsBtn->hide();
|
||||||
|
ui->label_4->hide();
|
||||||
|
ui->label_6->hide();
|
||||||
|
ui->updateBtn->hide();
|
||||||
|
ui->updateLabel->hide();
|
||||||
|
ui->enableLockscreenCheckBox->hide();
|
||||||
|
ui->setPasscodeBtn->hide();
|
||||||
|
ui->setPasscodeLabel->hide();
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
defineDefaultPageSize(0);
|
||||||
|
defineDefaultPageSize(1);
|
||||||
|
|
||||||
|
// Settings tweaking + enabling specific features whether it's running on the provided integrated OS or Kobo firmware
|
||||||
|
if (checkconfig(".config/01-demo/config") == true) {
|
||||||
|
ui->demoCheckBox->click();
|
||||||
|
}
|
||||||
|
if (checkconfig(".config/02-clock/config") == true) {
|
||||||
|
ui->clockCheckBox->click();
|
||||||
|
}
|
||||||
|
if (checkconfig(".config/05-quote/config") == true) {
|
||||||
|
ui->quoteCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->supportsNightmode()) {
|
||||||
|
if (checkconfig(".config/10-dark_mode/config") == true) {
|
||||||
|
ui->darkModeCheckBox->click();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ui->darkModeCheckBox->hide();
|
||||||
|
ui->darkModeCheckBox->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Words number
|
||||||
|
QString wordsNumberConfigStr = readFile(".config/07-words_number/config");
|
||||||
|
if (wordsNumberConfigStr.isEmpty()) {
|
||||||
|
Device::ScreenSize size = device->getScreenSize();
|
||||||
|
if (size == Device::ScreenSize::SMALL) {
|
||||||
|
wordsNumberSaved = 120;
|
||||||
|
} else if (size == Device::ScreenSize::VERY_LARGE) {
|
||||||
|
wordsNumberSaved = 250;
|
||||||
|
} else {
|
||||||
|
wordsNumberSaved = 175;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QString words_number = wordsNumberConfigStr;
|
||||||
|
wordsNumberSaved = wordsNumberConfigStr.toInt();
|
||||||
|
}
|
||||||
|
ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved));
|
||||||
|
|
||||||
|
// ePUB page size
|
||||||
|
if (checkconfig(".config/13-epub_page_size/set") == true) {
|
||||||
|
QString epubPageWidthSettingStr = readFile(".config/13-epub_page_size/width");
|
||||||
|
if (!epubPageWidthSettingStr.isEmpty()) {
|
||||||
|
QString pageWidth = epubPageWidthSettingStr;
|
||||||
|
ui->pageSizeWidthLabel->setText(pageWidth);
|
||||||
|
pageSizeWidthSaved = pageWidth.toInt();
|
||||||
|
} else {
|
||||||
|
// Failsafe: setting default
|
||||||
|
ui->pageSizeWidthLabel->setText(QString::number(defaultEpubPageWidth));
|
||||||
|
pageSizeWidthSaved = defaultEpubPageWidth;
|
||||||
|
}
|
||||||
|
QString epubPageHeightSettingStr = readFile(".config/13-epub_page_size/height");
|
||||||
|
if (!epubPageHeightSettingStr.isEmpty()) {
|
||||||
|
QString pageHeight = epubPageHeightSettingStr;
|
||||||
|
ui->pageSizeHeightLabel->setText(pageHeight);
|
||||||
|
pageSizeHeightSaved = pageHeight.toInt();
|
||||||
|
} else {
|
||||||
|
// Failsafe: setting default
|
||||||
|
ui->pageSizeHeightLabel->setText(QString::number(defaultEpubPageHeight));
|
||||||
|
pageSizeHeightSaved = defaultEpubPageHeight;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ui->pageSizeWidthLabel->setText(QString::number(defaultEpubPageWidth));
|
||||||
|
ui->pageSizeHeightLabel->setText(QString::number(defaultEpubPageHeight));
|
||||||
|
pageSizeHeightSaved = defaultEpubPageHeight;
|
||||||
|
pageSizeWidthSaved = defaultEpubPageWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// QTextEdit scroll bar in Reader framework
|
||||||
|
if (checkconfig(".config/14-reader_scrollbar/config") == true) {
|
||||||
|
ui->readerScrollBarCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sticky menubar
|
||||||
|
if (checkconfig(".config/11-menubar/sticky") == true) {
|
||||||
|
ui->menuBarCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh
|
||||||
|
QString refreshSettingStr = readFile(".config/04-book/refresh");
|
||||||
|
if (refreshSettingStr.isEmpty()) {
|
||||||
|
// Set default option, 3
|
||||||
|
writeFile(".config/04-book/refresh", "3");
|
||||||
|
ui->comboBox->setCurrentText("3 pages");
|
||||||
|
} else {
|
||||||
|
int refreshInt = refreshSettingStr.toInt();
|
||||||
|
if (refreshInt == -1) {
|
||||||
|
ui->comboBox->setCurrentText("Never refresh");
|
||||||
|
}
|
||||||
|
if (refreshInt == 0) {
|
||||||
|
ui->comboBox->setCurrentText("Every page");
|
||||||
|
}
|
||||||
|
if (refreshInt == 1) {
|
||||||
|
ui->comboBox->setCurrentText("1 page");
|
||||||
|
}
|
||||||
|
if (refreshInt == 2) {
|
||||||
|
ui->comboBox->setCurrentText("2 pages");
|
||||||
|
}
|
||||||
|
if (refreshInt == 3) {
|
||||||
|
ui->comboBox->setCurrentText("3 pages");
|
||||||
|
}
|
||||||
|
if (refreshInt == 4) {
|
||||||
|
ui->comboBox->setCurrentText("4 pages");
|
||||||
|
}
|
||||||
|
if (refreshInt == 5) {
|
||||||
|
ui->comboBox->setCurrentText("5 pages");
|
||||||
|
}
|
||||||
|
if (refreshInt == 6) {
|
||||||
|
ui->comboBox->setCurrentText("6 pages");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock screen
|
||||||
|
if (checkconfig(".config/12-lockscreen/config") == true) {
|
||||||
|
ui->enableLockscreenCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Global reading settings
|
||||||
|
if (checkconfig(".config/16-global_reading_settings/config") == true) {
|
||||||
|
ui->globalReadingSettingsCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encrypted storage
|
||||||
|
if (checkconfig(".config/18-encrypted_storage/status") == true) {
|
||||||
|
ui->enableEncryptedStorageCheckBox->click();
|
||||||
|
} else {
|
||||||
|
// Next interaction will be by the user
|
||||||
|
enableEncryptedStorageUserChange = true;
|
||||||
|
}
|
||||||
|
if (getEncFSStatus() == false) {
|
||||||
|
ui->repackLabel->hide();
|
||||||
|
ui->repackBtn->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timezone
|
||||||
|
ui->tzComboBox->addItems(QStringList(readFile(":/resources/tzlist").split("\n", Qt::SkipEmptyParts)));
|
||||||
|
timezone_not_user_change = true;
|
||||||
|
if (readFile(".config/19-timezone/config-name").isEmpty()) {
|
||||||
|
ui->tzComboBox->setCurrentText("UTC");
|
||||||
|
} else {
|
||||||
|
ui->tzComboBox->setCurrentText(readFile(".config/19-timezone/config-name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local library folders support
|
||||||
|
if (checkconfig(".config/21-local_library/folders") == true) {
|
||||||
|
ui->localLibraryShowFoldersCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// USB show dialog
|
||||||
|
if (checkconfig(".config/22-usb/show-dialog") == true) {
|
||||||
|
ui->usbmsDialogBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatic updates
|
||||||
|
if (checkconfig(".config/23-updates/check-updates") == true) {
|
||||||
|
ui->autoCheckUpdatesBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'Export highlights' button
|
||||||
|
if (!QFile::exists(global::localLibrary::highlightsDatabasePath) or readFile(global::localLibrary::highlightsDatabasePath).isEmpty()) {
|
||||||
|
ui->exportHighlightsBtn->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readFile(".config/12-lockscreen/background") == "blank") {
|
||||||
|
ui->lockscreenBackgroundComboBox->setCurrentIndex(0);
|
||||||
|
} else if (readFile(".config/12-lockscreen/background") == "screenSaver") {
|
||||||
|
ui->lockscreenBackgroundComboBox->setCurrentIndex(1);
|
||||||
|
} else if (readFile(".config/12-lockscreen/background") == "background") {
|
||||||
|
ui->lockscreenBackgroundComboBox->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
|
// Enforcing security policy if the user has not rooted the device
|
||||||
|
if (checkconfig("/external_root/opt/root/rooted") == true) {
|
||||||
|
ui->usbNetworkingCheckBox->show();
|
||||||
|
if (checkconfig("/external_root/boot/flags/USBNET_ENABLE")) {
|
||||||
|
ui->usbNetworkingCheckBox->click();
|
||||||
|
}
|
||||||
|
ui->requestLeaseBtn->show();
|
||||||
|
ui->label_4->show();
|
||||||
|
} else {
|
||||||
|
ui->usbNetworkingCheckBox->hide();
|
||||||
|
ui->requestLeaseBtn->hide();
|
||||||
|
ui->label_4->hide();
|
||||||
|
}
|
||||||
|
ui->enableLockscreenCheckBox->show();
|
||||||
|
ui->setPasscodeBtn->show();
|
||||||
|
ui->setPasscodeLabel->show();
|
||||||
|
ui->usbmsBtn->show();
|
||||||
|
ui->label_6->show();
|
||||||
|
} else {
|
||||||
|
ui->label_8->setText("Reset InkBox");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device->supportsWifi()) {
|
||||||
|
ui->checkOtaUpdateLabel->hide();
|
||||||
|
ui->checkOtaUpdateBtn->hide();
|
||||||
|
ui->checkOtaUpdateLabel->deleteLater();
|
||||||
|
ui->checkOtaUpdateBtn->deleteLater();
|
||||||
|
ui->checkOtaUpdateGridLayout->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsWidget::~SettingsWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_okBtn_clicked() {
|
||||||
|
saveDeferredSettings();
|
||||||
|
|
||||||
|
// Prevent potential unknown damage launching via shell script this could do
|
||||||
|
if (launch_sh == true) {
|
||||||
|
if (ui_enable_changed == true) {
|
||||||
|
ui_enable_changed = false;
|
||||||
|
global::settings::settingsRebootDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog();
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
} else {
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox.sh", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::saveDeferredSettings() {
|
||||||
|
// Save things
|
||||||
|
writeFile(".config/07-words_number/config", QString::number(wordsNumberSaved));
|
||||||
|
log("Set text files words number to " + QString::number(wordsNumberSaved), className);
|
||||||
|
|
||||||
|
writeFile(".config/13-epub_page_size/width", QString::number(pageSizeWidthSaved));
|
||||||
|
writeFile(".config/13-epub_page_size/set", "true");
|
||||||
|
|
||||||
|
writeFile(".config/13-epub_page_size/height", QString::number(pageSizeHeightSaved));
|
||||||
|
writeFile(".config/13-epub_page_size/set", "true");
|
||||||
|
|
||||||
|
// Notify power daemon of a potential configuration update
|
||||||
|
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/updateConfig", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_aboutBtn_clicked() {
|
||||||
|
log("Showing About message box", className);
|
||||||
|
if (checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
|
QString aboutmsg = "InkBox is an open-source, Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive.";
|
||||||
|
aboutmsg.prepend("<font face='u001'>");
|
||||||
|
aboutmsg.append("<br><br>InkBox ");
|
||||||
|
aboutmsg.append(readFile("/external_root/opt/isa/version"));
|
||||||
|
aboutmsg.append("</font>");
|
||||||
|
QMessageBox::information(this, tr("Information"), aboutmsg);
|
||||||
|
} else {
|
||||||
|
QMessageBox::information(this, tr("About"), tr("InkBox is an open-source Qt-based eBook reader. It aims to bring you the latest Qt features while being also fast and responsive."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_demoCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "change MainWindow label demo";
|
||||||
|
// Write to config file
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/01-demo/config", "InkboxChangeLabel=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/01-demo/config", "InkboxChangeLabel=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_clockCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "clock with seconds";
|
||||||
|
// Write to config file
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/02-clock/config", "ClockShowSeconds=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/02-clock/config", "ClockShowSeconds=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_quoteCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "disable show quotes";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/05-quote/config", "DisableQuote=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/05-quote/config", "DisableQuote=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_requestLeaseBtn_clicked() {
|
||||||
|
log("Requesting DHCP lease", className);
|
||||||
|
QString prog("chroot");
|
||||||
|
QStringList args;
|
||||||
|
args << "/external_root"
|
||||||
|
<< "/usr/sbin/dhclient";
|
||||||
|
QProcess *proc = new QProcess();
|
||||||
|
proc->start(prog, args);
|
||||||
|
proc->waitForFinished();
|
||||||
|
proc->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_usbmsBtn_clicked() {
|
||||||
|
usbms_launch();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_updateBtn_clicked() {
|
||||||
|
log("'Update' button clicked", className);
|
||||||
|
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "true\n");
|
||||||
|
writeFile("/external_root/opt/update/will_update", "true\n");
|
||||||
|
writeFile("/external_root/boot/flags/WILL_UPDATE", "true\n");
|
||||||
|
QString prog("/sbin/reboot");
|
||||||
|
QStringList args;
|
||||||
|
QProcess *proc = new QProcess();
|
||||||
|
proc->start(prog, args);
|
||||||
|
proc->waitForFinished();
|
||||||
|
proc->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_darkModeCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "dark mode";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
writeFile(".config/10-dark_mode/config", "true");
|
||||||
|
writeFile("/tmp/invertScreen", "y");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
writeFile(".config/10-dark_mode/config", "false");
|
||||||
|
writeFile("/tmp/invertScreen", "n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_menuBarCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "sticky menu bar";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/11-menubar/sticky", "StickyMenuBar=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/11-menubar/sticky", "StickyMenuBar=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_comboBox_currentIndexChanged(const QString &arg1) {
|
||||||
|
log("Setting page refresh setting to " + arg1, className);
|
||||||
|
if (arg1 == "Every page") {
|
||||||
|
writeFile(".config/04-book/refresh", "0");
|
||||||
|
}
|
||||||
|
if (arg1 == "1 page") {
|
||||||
|
writeFile(".config/04-book/refresh", "1");
|
||||||
|
}
|
||||||
|
if (arg1 == "2 pages") {
|
||||||
|
writeFile(".config/04-book/refresh", "2");
|
||||||
|
}
|
||||||
|
if (arg1 == "3 pages") {
|
||||||
|
writeFile(".config/04-book/refresh", "3");
|
||||||
|
}
|
||||||
|
if (arg1 == "4 pages") {
|
||||||
|
writeFile(".config/04-book/refresh", "4");
|
||||||
|
}
|
||||||
|
if (arg1 == "5 pages") {
|
||||||
|
writeFile(".config/04-book/refresh", "5");
|
||||||
|
}
|
||||||
|
if (arg1 == "6 pages") {
|
||||||
|
writeFile(".config/04-book/refresh", "6");
|
||||||
|
}
|
||||||
|
if (arg1 == "Never refresh") {
|
||||||
|
writeFile(".config/04-book/refresh", "-1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_resetBtn_clicked() {
|
||||||
|
log("'Reset' button clicked", className);
|
||||||
|
// We write to a temporary file to show a "Reset" prompt
|
||||||
|
writeFile("/inkbox/resetDialog", "true");
|
||||||
|
|
||||||
|
// We setup the dialog
|
||||||
|
log("Showing reset dialog", className);
|
||||||
|
generalDialogWindow = new GeneralDialog();
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_setPasscodeBtn_clicked() {
|
||||||
|
log("'Set passcode' button clicked", className);
|
||||||
|
log("Launching lockscreen binary", className);
|
||||||
|
saveDeferredSettings();
|
||||||
|
writeFile("/tmp/setPasscode", "true");
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("lockscreen", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_enableLockscreenCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "lockscreen";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
writeFile(".config/12-lockscreen/config", "true");
|
||||||
|
// Launching passcode setup wizard if none seems to be set at the moment
|
||||||
|
if (!(QFile::exists(".config/12-lockscreen/passcode") && QFile::exists(".config/12-lockscreen/salt"))) {
|
||||||
|
ui->setPasscodeBtn->click();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
writeFile(".config/12-lockscreen/config", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_showSystemInfoBtn_clicked() {
|
||||||
|
log("'Show system info' button clicked", className);
|
||||||
|
global::usbms::usbmsDialog = false;
|
||||||
|
|
||||||
|
Device::SysInfo info = Device::getSingleton()->getSystemInfo();
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
text = "<b>InkBox OS version ";
|
||||||
|
text.append(readFile("/external_root/opt/isa/version"));
|
||||||
|
text.append("</b><br>Copyright <font face='Inter'>©</font> 2021-2024 Nicolas Mailloux and contributors<br>Special thanks to: Szybet, NiLuJe, akemnade, Rain92, Ansraer (GitHub)");
|
||||||
|
text.append("<br><b>GUI Git commit:</b> ");
|
||||||
|
text.append(info.inkGitVersion);
|
||||||
|
text.append("<br><b>Device UID:</b> ");
|
||||||
|
text.append(info.uid);
|
||||||
|
text.append("<br><b>Kernel version:</b> ");
|
||||||
|
text.append(info.kernelVersion);
|
||||||
|
text.append("<br><b>Kernel build:</b> ");
|
||||||
|
text.append(info.kernelBuild);
|
||||||
|
text.append("<br><b>Kernel commit:</b> ");
|
||||||
|
text.append(info.kernelCommit);
|
||||||
|
text.append("<br><b>Device:</b> ");
|
||||||
|
QString device = Device::getSingleton()->getID();
|
||||||
|
text.append(device);
|
||||||
|
text.append("<br><b>IP address: </b>");
|
||||||
|
text.append(info.ipAddress);
|
||||||
|
|
||||||
|
global::text::textBrowserContents = text;
|
||||||
|
global::text::textBrowserDialog = true;
|
||||||
|
|
||||||
|
// Show a system info dialog
|
||||||
|
log("Showing system info dialog", className);
|
||||||
|
generalDialogWindow = new GeneralDialog();
|
||||||
|
generalDialogWindow->yIncrease = determineYIncrease();
|
||||||
|
generalDialogWindow->increaseSize();
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_readerScrollBarCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "scrollbar display if necessary";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
writeFile(".config/14-reader_scrollbar/config", "true");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
writeFile(".config/14-reader_scrollbar/config", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::brightnessDown() {
|
||||||
|
UI::transitionBrightness(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_globalReadingSettingsCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "global reading settings";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/16-global_reading_settings/config", "GlobalReadingSettings=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_checkOtaUpdateBtn_clicked() {
|
||||||
|
log("'Check for OTA update' button clicked", className);
|
||||||
|
if (testPing() == 0) {
|
||||||
|
launchOtaUpdater();
|
||||||
|
} else {
|
||||||
|
emit showToast("Wi-Fi connection error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::openUpdateDialog() {
|
||||||
|
log("Showing update dialog", className);
|
||||||
|
global::mainwindow::updateDialog = true;
|
||||||
|
// Write to a temporary file to show an "Update" prompt
|
||||||
|
writeFile("/inkbox/updateDialog", "true");
|
||||||
|
|
||||||
|
// Show the dialog
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
||||||
|
connect(generalDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToastNative()));
|
||||||
|
QApplication::processEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::launchOtaUpdater() {
|
||||||
|
global::toast::modalToast = true;
|
||||||
|
global::toast::indefiniteToast = true;
|
||||||
|
emit showToast("Checking for updates");
|
||||||
|
otaManagerWindow = new OTAUpdateManagerWidget(this);
|
||||||
|
connect(otaManagerWindow, SIGNAL(canOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
|
||||||
|
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::openUpdateDialogOTA(bool open) {
|
||||||
|
emit closeIndefiniteToast();
|
||||||
|
if (open == true) {
|
||||||
|
global::otaUpdate::isUpdateOta = true;
|
||||||
|
openUpdateDialog();
|
||||||
|
} else {
|
||||||
|
emit showToast("No update available");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::showToastNative(QString messageToDisplay) {
|
||||||
|
emit showToast(messageToDisplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::closeIndefiniteToastNative() {
|
||||||
|
emit closeIndefiniteToast();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::usbms_launch() {
|
||||||
|
log("Showing USBMS splash", className);
|
||||||
|
global::usbms::launchUsbms = true;
|
||||||
|
|
||||||
|
usbmsWindow = new USBMSSplashWidget();
|
||||||
|
usbmsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
usbmsWindow->setGeometry(QRect(QPoint(0, 0), screen()->geometry().size()));
|
||||||
|
usbmsWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::quit_restart() {
|
||||||
|
// If existing, cleaning bookconfig_mount mountpoint
|
||||||
|
writeFile("/opt/ibxd", "bookconfig_unmount\n");
|
||||||
|
|
||||||
|
// Restarting InkBox
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_enableEncryptedStorageCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "encrypted storage";
|
||||||
|
if (checked == true) {
|
||||||
|
if (enableEncryptedStorageUserChange == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile(".config/18-encrypted_storage/initial_setup_done", "false");
|
||||||
|
writeFile(".config/18-encrypted_storage/status", "true");
|
||||||
|
if (QFile::exists(".config/18-encrypted_storage/storage_list")) {
|
||||||
|
QFile::remove(".config/18-encrypted_storage/storage_list");
|
||||||
|
}
|
||||||
|
global::settings::settingsRebootDialog = true;
|
||||||
|
global::encfs::enableStorageEncryptionDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
} else {
|
||||||
|
enableEncryptedStorageUserChange = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
global::encfs::disableStorageEncryptionDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(generalDialogWindow, SIGNAL(cancelDisableStorageEncryption()), SLOT(cancelDisableStorageEncryption()));
|
||||||
|
connect(generalDialogWindow, SIGNAL(disableStorageEncryption()), SLOT(disableStorageEncryption()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::disableStorageEncryption() {
|
||||||
|
log("Disabling encrypted storage", className);
|
||||||
|
setDefaultWorkDir();
|
||||||
|
writeFile("/external_root/run/encfs_stop_cleanup", "true");
|
||||||
|
writeFile("/opt/ibxd", "encfs_stop\n");
|
||||||
|
QThread::msleep(5000);
|
||||||
|
|
||||||
|
writeFile(".config/18-encrypted_storage/status", "false");
|
||||||
|
QFile::remove(".config/18-encrypted_storage/initial_setup_done");
|
||||||
|
QFile::remove(".config/18-encrypted_storage/storage_list");
|
||||||
|
QFile::remove("/mnt/onboard/onboard/data.encfs");
|
||||||
|
|
||||||
|
QDir dumpDir("/mnt/onboard/onboard/encfs-dropbox");
|
||||||
|
dumpDir.removeRecursively();
|
||||||
|
QDir decDir("/mnt/onboard/onboard/encfs-decrypted");
|
||||||
|
decDir.removeRecursively();
|
||||||
|
|
||||||
|
global::settings::settingsRebootDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::cancelDisableStorageEncryption() {
|
||||||
|
enableEncryptedStorageUserChange = false;
|
||||||
|
ui->enableEncryptedStorageCheckBox->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_repackBtn_clicked() {
|
||||||
|
log("'Repack encrypted storage' button clicked", className);
|
||||||
|
QDir dir("/mnt/onboard/onboard/encfs-dropbox");
|
||||||
|
if (dir.isEmpty()) {
|
||||||
|
log("Showing encrypted storage repack error dialog ('encfs-dropbox' directory is empty)", className);
|
||||||
|
global::encfs::errorNoBooksInDropboxDialog = true;
|
||||||
|
generalDialogWindow = new GeneralDialog(this);
|
||||||
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
} else {
|
||||||
|
log("Showing encrypted storage repack dialog", className);
|
||||||
|
writeFile("/external_root/run/encfs_repack", "true");
|
||||||
|
quit_restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_generateSystemReportBtn_clicked() {
|
||||||
|
log("'Generate system report' button clicked", className);
|
||||||
|
log("Generating system report", className);
|
||||||
|
writeFile("/opt/ibxd", "generate_system_report\n");
|
||||||
|
while (true) {
|
||||||
|
if (QFile::exists("/inkbox/systemReportDone")) {
|
||||||
|
if (checkconfig("/inkbox/systemReportDone") == true) {
|
||||||
|
QFile::remove(global::localLibrary::databasePath);
|
||||||
|
emit showToast("System report generated successfully");
|
||||||
|
} else {
|
||||||
|
emit showToast("Error in generating system report");
|
||||||
|
}
|
||||||
|
QFile::remove("/inkbox/systemReportDone");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_tzComboBox_currentTextChanged(const QString &arg1) {
|
||||||
|
if (timezone_not_user_change == true) {
|
||||||
|
timezone_not_user_change = false;
|
||||||
|
} else {
|
||||||
|
log("Setting timezone to " + arg1, className);
|
||||||
|
setDefaultWorkDir();
|
||||||
|
// Preventing unnecessary (e)MMC writes
|
||||||
|
if (readFile(".config/19-timezone/config-name") != arg1) {
|
||||||
|
QProcess::execute("ln", QStringList() << "-sf"
|
||||||
|
<< "/usr/share/zoneinfo/" + arg1 << ".config/19-timezone/config");
|
||||||
|
writeFile(".config/19-timezone/config-name", arg1);
|
||||||
|
writeFile("/opt/ibxd", "gui_remount_localtime\n");
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_exportHighlightsBtn_clicked() {
|
||||||
|
QJsonObject jsonObject = readHighlightsDatabase();
|
||||||
|
writeFile("/mnt/onboard/onboard/highlights-" + QDateTime::currentDateTime().toString("dd-MM-yy_hh.mm.ss") + ".json", QJsonDocument(jsonObject).toJson());
|
||||||
|
showToast("Highlights exported successfully");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_wordsNumberIncBtn_clicked() {
|
||||||
|
wordsNumberSaved = wordsNumberSaved + 5;
|
||||||
|
ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_wordsNumberDecBtn_clicked() {
|
||||||
|
if (wordsNumberSaved > 10) {
|
||||||
|
wordsNumberSaved = wordsNumberSaved - 5;
|
||||||
|
ui->wordsNumberValueLabel->setText(QString::number(wordsNumberSaved));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_pageSizeHeightDecBtn_clicked() {
|
||||||
|
if (pageSizeHeightSaved > 100) {
|
||||||
|
pageSizeHeightSaved = pageSizeHeightSaved - 5;
|
||||||
|
ui->pageSizeHeightLabel->setText(QString::number(pageSizeHeightSaved));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_pageSizeHeightIncBtn_clicked() {
|
||||||
|
pageSizeHeightSaved = pageSizeHeightSaved + 5;
|
||||||
|
ui->pageSizeHeightLabel->setText(QString::number(pageSizeHeightSaved));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_pageSizeWidthDecBtn_clicked() {
|
||||||
|
if (pageSizeWidthSaved > 100) {
|
||||||
|
pageSizeWidthSaved = pageSizeWidthSaved - 5;
|
||||||
|
ui->pageSizeWidthLabel->setText(QString::number(pageSizeWidthSaved));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_pageSizeWidthIncBtn_clicked() {
|
||||||
|
pageSizeWidthSaved = pageSizeWidthSaved + 5;
|
||||||
|
ui->pageSizeWidthLabel->setText(QString::number(pageSizeWidthSaved));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_localLibraryShowFoldersCheckBox_toggled(bool checked) {
|
||||||
|
QString settingString = "local library folders support";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
checked_box = true;
|
||||||
|
writeconfig(".config/21-local_library/folders", "Folders=");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
checked_box = false;
|
||||||
|
writeconfig(".config/21-local_library/folders", "Folders=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_usbmsDialogBox_clicked(bool checked) {
|
||||||
|
QString settingString = "USB Mass Storage dialog display";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
writeFile(".config/22-usb/show-dialog", "true");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
writeFile(".config/22-usb/show-dialog", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_autoCheckUpdatesBox_clicked(bool checked) {
|
||||||
|
QString settingString = "automatic updates checking";
|
||||||
|
if (checked == true) {
|
||||||
|
logEnabled(settingString, className);
|
||||||
|
writeFile(".config/23-updates/check-updates", "true");
|
||||||
|
} else {
|
||||||
|
logDisabled(settingString, className);
|
||||||
|
writeFile(".config/23-updates/check-updates", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_lockscreenBackgroundComboBox_currentTextChanged(const QString &arg1) {
|
||||||
|
if (arg1 == "Blank") {
|
||||||
|
writeFile(".config/12-lockscreen/background", "blank");
|
||||||
|
log("Set lockscreen background to 'blank'", className);
|
||||||
|
} else if (arg1 == "Screensaver picture") {
|
||||||
|
writeFile(".config/12-lockscreen/background", "screenSaver");
|
||||||
|
log("Set lockscreen background to 'screenSaver'", className);
|
||||||
|
} else if (arg1 == "Device's screen") {
|
||||||
|
writeFile(".config/12-lockscreen/background", "background");
|
||||||
|
log("Set lockscreen background to 'background'", className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_settingsStackedWidget_currentChanged(int arg1) {
|
||||||
|
if (ui->settingsStackedWidget->currentIndex() != 0) {
|
||||||
|
ui->headerLabel->setText(ui->settingsStackedWidget->currentWidget()->objectName());
|
||||||
|
ui->headerStackedWidget->show();
|
||||||
|
} else {
|
||||||
|
ui->headerStackedWidget->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_readingSettingsBtn_clicked() {
|
||||||
|
log("'Reading settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_homeSettingsBtn_clicked() {
|
||||||
|
log("'Home settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_librarySettingsBtn_clicked() {
|
||||||
|
log("'Library settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_storageSettingsBtn_clicked() {
|
||||||
|
log("'Storage settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_systemSettingsBtn_clicked() {
|
||||||
|
log("'System settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_securitySettingsBtn_clicked() {
|
||||||
|
log("'Security settings' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_headerBtn_clicked() {
|
||||||
|
// "Home" button
|
||||||
|
log("'Home' button clicked", className);
|
||||||
|
ui->settingsStackedWidget->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWidget::on_usbNetworkingCheckBox_toggled(bool checked) {
|
||||||
|
if (checked) {
|
||||||
|
writeFile("/external_root/boot/flags/USBNET_ENABLE", "true");
|
||||||
|
writeFile("/opt/ibxd", "usbnet_start\n");
|
||||||
|
} else {
|
||||||
|
writeFile("/external_root/boot/flags/USBNET_ENABLE", "false");
|
||||||
|
writeFile("/opt/ibxd", "usbnet_stop\n");
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,10 +11,10 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class settings;
|
class SettingsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class settings : public QWidget
|
class SettingsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ public:
|
||||||
float homeIconWidth;
|
float homeIconWidth;
|
||||||
float homeIconHeight;
|
float homeIconHeight;
|
||||||
|
|
||||||
explicit settings(QWidget *parent = nullptr);
|
explicit SettingsWidget(QWidget *parent = nullptr);
|
||||||
~settings();
|
~SettingsWidget();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_demoCheckBox_toggled(bool);
|
void on_demoCheckBox_toggled(bool);
|
||||||
|
@ -46,7 +46,6 @@ private slots:
|
||||||
void on_usbmsBtn_clicked();
|
void on_usbmsBtn_clicked();
|
||||||
void on_updateBtn_clicked();
|
void on_updateBtn_clicked();
|
||||||
void on_darkModeCheckBox_toggled(bool checked);
|
void on_darkModeCheckBox_toggled(bool checked);
|
||||||
void on_uiScalingSlider_valueChanged(int value);
|
|
||||||
void on_menuBarCheckBox_toggled(bool checked);
|
void on_menuBarCheckBox_toggled(bool checked);
|
||||||
void on_comboBox_currentIndexChanged(const QString &arg1);
|
void on_comboBox_currentIndexChanged(const QString &arg1);
|
||||||
void on_resetBtn_clicked();
|
void on_resetBtn_clicked();
|
||||||
|
@ -97,10 +96,10 @@ signals:
|
||||||
void closeIndefiniteToast();
|
void closeIndefiniteToast();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::settings * ui;
|
Ui::SettingsWidget * ui;
|
||||||
usbmsSplash * usbmsWindow;
|
USBMSSplashWidget * usbmsWindow;
|
||||||
generalDialog * generalDialogWindow;
|
GeneralDialog * generalDialogWindow;
|
||||||
otaManager * otaManagerWindow;
|
OTAUpdateManagerWidget * otaManagerWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
|
|
||||||
int pageSizeHeightSaved;
|
int pageSizeHeightSaved;
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>settings</class>
|
<class>SettingsWidget</class>
|
||||||
<widget class="QWidget" name="settings">
|
<widget class="QWidget" name="SettingsWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -19,13 +19,13 @@
|
||||||
<item row="28" column="0">
|
<item row="28" column="0">
|
||||||
<widget class="Line" name="line_5">
|
<widget class="Line" name="line_5">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
<property name="lineWidth">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<spacer name="horizontalSpacer_4">
|
<spacer name="horizontalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<string>InkBox settings</string>
|
<string>InkBox settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -94,10 +94,13 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="page">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -114,7 +117,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -129,7 +132,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_19">
|
<spacer name="horizontalSpacer_19">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -151,13 +154,13 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_12">
|
<widget class="Line" name="line_12">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
<property name="lineWidth">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -190,7 +193,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::Shape::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -200,8 +203,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>461</width>
|
<width>463</width>
|
||||||
<height>636</height>
|
<height>587</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
@ -227,10 +230,10 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_13">
|
<widget class="Line" name="line_13">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -244,10 +247,10 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_14">
|
<widget class="Line" name="line_14">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -261,10 +264,10 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_15">
|
<widget class="Line" name="line_15">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -278,10 +281,10 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_16">
|
<widget class="Line" name="line_16">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -295,10 +298,10 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_17">
|
<widget class="Line" name="line_17">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -312,7 +315,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_3">
|
<spacer name="verticalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -329,13 +332,13 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_18">
|
<widget class="Line" name="line_18">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
<property name="lineWidth">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -349,13 +352,13 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_2">
|
<widget class="Line" name="line_2">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
<property name="lineWidth">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -394,10 +397,10 @@ Save && Quit
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea_2">
|
<widget class="QScrollArea" name="scrollArea_2">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::Shape::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Shadow::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -407,8 +410,8 @@ Save && Quit
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>423</width>
|
<width>425</width>
|
||||||
<height>738</height>
|
<height>723</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
@ -454,7 +457,7 @@ Save && Quit
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<spacer name="horizontalSpacer_5">
|
<spacer name="horizontalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -532,7 +535,7 @@ Save && Quit
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer_11">
|
<spacer name="horizontalSpacer_11">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -577,7 +580,7 @@ Save && Quit
|
||||||
<item row="1" column="6">
|
<item row="1" column="6">
|
||||||
<spacer name="horizontalSpacer_17">
|
<spacer name="horizontalSpacer_17">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -604,7 +607,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_7">
|
<spacer name="horizontalSpacer_7">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -701,7 +704,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_12">
|
<spacer name="horizontalSpacer_12">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -723,7 +726,7 @@ Save && Quit
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_4">
|
<spacer name="verticalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -779,7 +782,7 @@ Save && Quit
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<spacer name="verticalSpacer_5">
|
<spacer name="verticalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -819,7 +822,7 @@ Save && Quit
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_6">
|
<spacer name="verticalSpacer_6">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -879,7 +882,7 @@ Save && Quit
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -901,7 +904,7 @@ Save && Quit
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<spacer name="verticalSpacer_7">
|
<spacer name="verticalSpacer_7">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -937,7 +940,7 @@ Save && Quit
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="5" column="0">
|
<item row="4" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_7">
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -955,7 +958,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_6">
|
<spacer name="horizontalSpacer_6">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -979,7 +982,53 @@ Save && Quit
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="5" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_19">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="generateSystemReportBtn">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Generate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_15">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Generate system report</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="usbNetworkingCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable USB networking</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
|
<layout class="QGridLayout" name="checkOtaUpdateGridLayout">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -999,7 +1048,7 @@ Save && Quit
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<spacer name="horizontalSpacer_13">
|
<spacer name="horizontalSpacer_13">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1018,10 +1067,82 @@ Save && Quit
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0">
|
<item row="7" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_14">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="updateBtn">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Update</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_10">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="updateLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update InkBox</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_18">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_16">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QComboBox" name="tzComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timezone</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
<spacer name="verticalSpacer_8">
|
<spacer name="verticalSpacer_8">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1039,7 +1160,7 @@ Save && Quit
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1070,56 +1191,27 @@ Save && Quit
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_14">
|
<widget class="QCheckBox" name="autoCheckUpdatesBox">
|
||||||
<property name="bottomMargin">
|
<property name="sizePolicy">
|
||||||
<number>0</number>
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
</property>
|
<horstretch>0</horstretch>
|
||||||
<item row="0" column="2">
|
<verstretch>0</verstretch>
|
||||||
<widget class="QPushButton" name="updateBtn">
|
</sizepolicy>
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Update</string>
|
<string>Automatically check for updates</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="2" column="0">
|
||||||
<spacer name="horizontalSpacer_10">
|
|
||||||
<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="0">
|
|
||||||
<widget class="QLabel" name="updateLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Update InkBox</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QCheckBox" name="darkModeCheckBox">
|
<widget class="QCheckBox" name="darkModeCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable night mode</string>
|
<string>Enable night mode</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="3" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_12">
|
<layout class="QGridLayout" name="gridLayout_12">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -1139,7 +1231,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_8">
|
<spacer name="horizontalSpacer_8">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1158,146 +1250,6 @@ Save && Quit
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_8">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QLabel" name="uiScaleNumberLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>1</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QSlider" name="uiScalingSlider">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="pageStep">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="uiScalingLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>UI scaling factor</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_19">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="generateSystemReportBtn">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Generate</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="horizontalSpacer_15">
|
|
||||||
<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="0">
|
|
||||||
<widget class="QLabel" name="label_10">
|
|
||||||
<property name="text">
|
|
||||||
<string>Generate system report</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="10" column="0">
|
|
||||||
<widget class="QCheckBox" name="autoCheckUpdatesBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Automatically check for updates</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_18">
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="horizontalSpacer_16">
|
|
||||||
<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="2">
|
|
||||||
<widget class="QComboBox" name="tzComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_11">
|
|
||||||
<property name="text">
|
|
||||||
<string>Timezone</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QCheckBox" name="usbNetworkingCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable USB networking</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -1329,7 +1281,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_14">
|
<spacer name="horizontalSpacer_14">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1368,7 +1320,7 @@ Save && Quit
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<spacer name="horizontalSpacer_18">
|
<spacer name="horizontalSpacer_18">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1436,10 +1388,10 @@ Save && Quit
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="Line" name="line_10">
|
<widget class="Line" name="line_10">
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Shadow::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1451,7 +1403,7 @@ Save && Quit
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<spacer name="horizontalSpacer_9">
|
<spacer name="horizontalSpacer_9">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1485,7 +1437,7 @@ Save && Quit
|
||||||
<item row="8" column="0">
|
<item row="8" column="0">
|
||||||
<spacer name="verticalSpacer_9">
|
<spacer name="verticalSpacer_9">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
101
src/ui/settings/settingschooser.cpp
Normal file
101
src/ui/settings/settingschooser.cpp
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
#include "settingschooser.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "powerdaemonsettings.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_settingschooser.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
SettingsChooserWidget::SettingsChooserWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::SettingsChooserWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// Stylesheet
|
||||||
|
UI::applyStyle(*this, "eink");
|
||||||
|
|
||||||
|
// UI tweaks
|
||||||
|
if (checkconfig("/opt/inkbox_kobox_support") == false) {
|
||||||
|
ui->koboxSettingsBtn->hide();
|
||||||
|
ui->line_3->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getting the screen's size
|
||||||
|
sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
|
||||||
|
Device::ScreenSize screenSize = Device::getSingleton()->getScreenSize();
|
||||||
|
QString padding = "";
|
||||||
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
|
homeIconWidth = sW / 18;
|
||||||
|
homeIconHeight = sW / 18;
|
||||||
|
padding = "18px";
|
||||||
|
} else if (screenSize == Device::ScreenSize::MEDIUM) {
|
||||||
|
homeIconWidth = sW / 20;
|
||||||
|
homeIconHeight = sW / 20;
|
||||||
|
padding = "20px";
|
||||||
|
} else if (screenSize == Device::ScreenSize::LARGE) {
|
||||||
|
homeIconWidth = sW / 20;
|
||||||
|
homeIconHeight = sW / 20;
|
||||||
|
padding = "25px";
|
||||||
|
} else if (screenSize == Device::ScreenSize::VERY_LARGE) {
|
||||||
|
homeIconWidth = sW / 20;
|
||||||
|
homeIconHeight = sW / 20;
|
||||||
|
padding = "40px";
|
||||||
|
}
|
||||||
|
ui->inkboxSettingsBtn->setStyleSheet("padding: " + padding + "; Text-align: left");
|
||||||
|
ui->koboxSettingsBtn->setStyleSheet("padding: " + padding + "; Text-align: left");
|
||||||
|
ui->powerSettingsBtn->setStyleSheet("padding: " + padding + "; Text-align: left");
|
||||||
|
|
||||||
|
ui->inkboxSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->koboxSettingsBtn->setProperty("type", "borderless");
|
||||||
|
ui->powerSettingsBtn->setProperty("type", "borderless");
|
||||||
|
|
||||||
|
ui->inkboxSettingsBtn->setText("\t\t\tInkBox settings");
|
||||||
|
ui->koboxSettingsBtn->setText("\t\t\tKoBox settings");
|
||||||
|
ui->powerSettingsBtn->setText("\t\t\tPower settings");
|
||||||
|
|
||||||
|
ui->inkboxSettingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||||
|
ui->inkboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
ui->koboxSettingsBtn->setIcon(QIcon(":/resources/X11.png"));
|
||||||
|
ui->koboxSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
ui->powerSettingsBtn->setIcon(QIcon(":/resources/power.png"));
|
||||||
|
ui->powerSettingsBtn->setIconSize(QSize(homeIconWidth, homeIconHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsChooserWidget::~SettingsChooserWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsChooserWidget::on_inkboxSettingsBtn_clicked() {
|
||||||
|
log("Launching InkBox Settings", className);
|
||||||
|
settingsWindow = new SettingsWidget();
|
||||||
|
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(settingsWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
|
||||||
|
connect(settingsWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToastNative()));
|
||||||
|
settingsWindow->showFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsChooserWidget::on_koboxSettingsBtn_clicked() {
|
||||||
|
log("Launching KoBox Settings", className);
|
||||||
|
koboxSettingsWindow = new KoboxSettingsWidget();
|
||||||
|
koboxSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
koboxSettingsWindow->showFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsChooserWidget::on_powerSettingsBtn_clicked() {
|
||||||
|
log("Launching Power Daemon Settings", className);
|
||||||
|
PowerDaemonSettingsWidget *powerSettingsWindow = new PowerDaemonSettingsWidget();
|
||||||
|
powerSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
powerSettingsWindow->showFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsChooserWidget::showToastNative(QString messageToDisplay) {
|
||||||
|
emit showToast(messageToDisplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsChooserWidget::closeIndefiniteToastNative() {
|
||||||
|
emit closeIndefiniteToast();
|
||||||
|
}
|
|
@ -7,17 +7,17 @@
|
||||||
#include "koboxsettings.h"
|
#include "koboxsettings.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class settingsChooser;
|
class SettingsChooserWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class settingsChooser : public QWidget
|
class SettingsChooserWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit settingsChooser(QWidget *parent = nullptr);
|
explicit SettingsChooserWidget(QWidget *parent = nullptr);
|
||||||
~settingsChooser();
|
~SettingsChooserWidget();
|
||||||
|
|
||||||
float sW;
|
float sW;
|
||||||
float sH;
|
float sH;
|
||||||
|
@ -36,9 +36,9 @@ signals:
|
||||||
void closeIndefiniteToast();
|
void closeIndefiniteToast();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::settingsChooser *ui;
|
Ui::SettingsChooserWidget *ui;
|
||||||
settings *settingsWindow;
|
SettingsWidget *settingsWindow;
|
||||||
koboxSettings *koboxSettingsWindow;
|
KoboxSettingsWidget *koboxSettingsWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSCHOOSER_H
|
#endif // SETTINGSCHOOSER_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>settingsChooser</class>
|
<class>SettingsChooserWidget</class>
|
||||||
<widget class="QWidget" name="settingsChooser">
|
<widget class="QWidget" name="SettingsChooserWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
161
src/ui/splash/splashAlert.cpp
Normal file
161
src/ui/splash/splashAlert.cpp
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
#include "splashAlert.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "ui_splashAlert.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
SplashAlertWidget::SplashAlertWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::SplashAlertWidget) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->messageLabel->setFont(QFont("u001"));
|
||||||
|
|
||||||
|
// Getting the screen's size
|
||||||
|
float sW = QGuiApplication::screens()[0]->size().width();
|
||||||
|
float sH = QGuiApplication::screens()[0]->size().height();
|
||||||
|
// Defining what the "Alert" icon size will be
|
||||||
|
float stdIconWidth = sW / 1.7;
|
||||||
|
float stdIconHeight = sH / 1.7;
|
||||||
|
|
||||||
|
// General stylesheet
|
||||||
|
UI::applyStyle(*this, ":/resources/eink-dark.qss");
|
||||||
|
|
||||||
|
// Default icon in case none of the conditions below are met
|
||||||
|
QPixmap pixmap(":/resources/alert.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
// Checking if the update's signature is untrusted. The signature error will always take precedence over the downgrade one (c.f. update.sh script)
|
||||||
|
if (checkconfig("/external_root/boot/flags/ALERT_SIGN") == true) {
|
||||||
|
QPixmap pixmap(":/resources/alert.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
signatureError = true;
|
||||||
|
log("Displaying signature error alert splash", className);
|
||||||
|
ui->securityLabel->setText("Failed to update InkBox.");
|
||||||
|
ui->messageLabel->setText("The digital signature of the update is untrusted.\nFor security reasons, it cannot be installed.");
|
||||||
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
if (checkconfig("/external_root/boot/flags/ALERT_DOWNGRADE") == true) {
|
||||||
|
QPixmap pixmap(":/resources/alert.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
log("Displaying downgrade error alert splash", className);
|
||||||
|
downgradeError = true;
|
||||||
|
ui->securityLabel->setText("Failed to update InkBox.");
|
||||||
|
ui->messageLabel->setText("An error occured during the update process.\nThe update package's version is lower than the actual installed version.");
|
||||||
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
if (global::encfs::lockdown == true) {
|
||||||
|
ui->stackedWidget->setVisible(false);
|
||||||
|
ui->stackedWidget->deleteLater();
|
||||||
|
QPixmap pixmap(":/resources/alert.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
ui->warningLabel->setText("Fatal error");
|
||||||
|
ui->securityLabel->setText("Device lockdown");
|
||||||
|
log(global::encfs::lockdownMessage, className);
|
||||||
|
QString message = "Due to multiple incorrect passphrase attempts, this device is locked down until\n" + global::encfs::unlockTime + "\nand won't boot.";
|
||||||
|
ui->messageLabel->setText(message);
|
||||||
|
poweroff(false);
|
||||||
|
QTimer::singleShot(1000, this, SLOT(quit()));
|
||||||
|
}
|
||||||
|
if (global::battery::showCriticalBatteryAlert == true) {
|
||||||
|
global::battery::showCriticalBatteryAlert = false;
|
||||||
|
ui->stackedWidget->setVisible(false);
|
||||||
|
ui->stackedWidget->deleteLater();
|
||||||
|
|
||||||
|
QPixmap pixmap(":/resources/battery_alert.png");
|
||||||
|
QPixmap scaledPixmap = pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
ui->alertIconLabel->setPixmap(scaledPixmap);
|
||||||
|
|
||||||
|
log("Displaying critical battery alert splash", className);
|
||||||
|
criticalBattery = true;
|
||||||
|
ui->warningLabel->setText("Please charge your eReader.");
|
||||||
|
ui->securityLabel->setText("The battery's charge level is critical.");
|
||||||
|
ui->messageLabel->setText("To prevent damage, your device has been turned off.\nPlease consider charging it.");
|
||||||
|
// The Mini (N705) has a higher DPI and otherwise the text doesn't fit
|
||||||
|
Device::ScreenSize screenSize = Device::getSingleton()->getScreenSize();
|
||||||
|
if (screenSize == Device::ScreenSize::SMALL) {
|
||||||
|
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 14pt }");
|
||||||
|
} else {
|
||||||
|
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt }");
|
||||||
|
}
|
||||||
|
poweroff(false);
|
||||||
|
QTimer::singleShot(1000, this, SLOT(quit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 10pt }");
|
||||||
|
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt }");
|
||||||
|
ui->continueBtn->setProperty("type", "borderless");
|
||||||
|
ui->resetBtn->setProperty("type", "borderless");
|
||||||
|
ui->continueBtn->setStyleSheet("padding: 20px");
|
||||||
|
ui->resetBtn->setStyleSheet("padding: 20px");
|
||||||
|
ui->continue2Btn->setProperty("type", "borderless");
|
||||||
|
ui->continue2Btn->setStyleSheet("padding: 20px");
|
||||||
|
}
|
||||||
|
|
||||||
|
SplashAlertWidget::~SplashAlertWidget() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashAlertWidget::on_continueBtn_clicked() {
|
||||||
|
// We continue anyway and re-set the ALERT flag
|
||||||
|
writeFile("/external_root/boot/flags/ALERT", "false\n");
|
||||||
|
writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n");
|
||||||
|
updateReset();
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashAlertWidget::on_resetBtn_clicked() {
|
||||||
|
// We set the DO_FACTORY_RESET flag and we restart the device
|
||||||
|
log("Factory reset requested; setting required flags", className);
|
||||||
|
writeFile("/external_root/boot/flags/DO_FACTORY_RESET", "true\n");
|
||||||
|
writeFile("/external_root/boot/flags/DIAGS_BOOT", "true\n");
|
||||||
|
QString reboot_prog("/sbin/reboot");
|
||||||
|
QStringList reboot_args;
|
||||||
|
reboot_args << "no_splash";
|
||||||
|
QProcess *reboot_proc = new QProcess();
|
||||||
|
reboot_proc->start(reboot_prog, reboot_args);
|
||||||
|
reboot_proc->waitForFinished();
|
||||||
|
reboot_proc->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashAlertWidget::on_continue2Btn_clicked() {
|
||||||
|
// We continue anyway and re-set the ALERT flag
|
||||||
|
writeFile("/external_root/boot/flags/ALERT", "false\n");
|
||||||
|
updateReset();
|
||||||
|
|
||||||
|
log("Restarting InkBox", className);
|
||||||
|
if (signatureError == true) {
|
||||||
|
writeFile("/external_root/boot/flags/ALERT_SIGN", "false\n");
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
if (downgradeError == true) {
|
||||||
|
writeFile("/external_root/boot/flags/ALERT_DOWNGRADE", "false\n");
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("inkbox", QStringList());
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashAlertWidget::updateReset() {
|
||||||
|
writeFile("/mnt/onboard/onboard/.inkbox/can_really_update", "false\n");
|
||||||
|
writeFile("/mnt/onboard/onboard/.inkbox/can_update", "false\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashAlertWidget::quit() {
|
||||||
|
qApp->quit();
|
||||||
|
}
|
|
@ -1,22 +1,22 @@
|
||||||
#ifndef ALERT_H
|
#ifndef SPLASHALERT_H
|
||||||
#define ALERT_H
|
#define SPLASHALERT_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class alert;
|
class SplashAlertWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class alert : public QWidget
|
class SplashAlertWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString className = this->metaObject()->className();
|
QString className = this->metaObject()->className();
|
||||||
explicit alert(QWidget *parent = nullptr);
|
explicit SplashAlertWidget(QWidget *parent = nullptr);
|
||||||
~alert();
|
~SplashAlertWidget();
|
||||||
bool signatureError = false;
|
bool signatureError = false;
|
||||||
bool downgradeError = false;
|
bool downgradeError = false;
|
||||||
bool criticalBattery = false;
|
bool criticalBattery = false;
|
||||||
|
@ -29,7 +29,7 @@ private slots:
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::alert *ui;
|
Ui::SplashAlertWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALERT_H
|
#endif // SPLASHALERT_H
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue