mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Dispatcher: add Battery & System statistics
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local DataStorage = require("datastorage")
|
||||
local Dispatcher = require("dispatcher")
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local LuaSettings = require("luasettings")
|
||||
local PowerD = require("device"):getPowerDevice()
|
||||
@@ -269,9 +270,14 @@ local BatteryStatWidget = WidgetContainer:new{
|
||||
name = "batterystat",
|
||||
}
|
||||
|
||||
function BatteryStatWidget:onDispatcherRegisterActions()
|
||||
Dispatcher:registerAction("battery_statistics", {category="none", event="ShowBatteryStatistics", title=_("Battery statistics"), device=true, separator=true})
|
||||
end
|
||||
|
||||
function BatteryStatWidget:init()
|
||||
-- self.ui is nil in test cases.
|
||||
if not self.ui or not self.ui.menu then return end
|
||||
self:onDispatcherRegisterActions()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
@@ -285,6 +291,10 @@ function BatteryStatWidget:addToMainMenu(menu_items)
|
||||
}
|
||||
end
|
||||
|
||||
function BatteryStatWidget:onShowBatteryStatistics()
|
||||
BatteryStat:showStatistics()
|
||||
end
|
||||
|
||||
function BatteryStatWidget:onFlushSettings()
|
||||
BatteryStat:onFlushSettings()
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local Device = require("device")
|
||||
local Dispatcher = require("dispatcher")
|
||||
local KeyValuePage = require("ui/widget/keyvaluepage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
@@ -254,7 +255,12 @@ local SystemStatWidget = WidgetContainer:new{
|
||||
name = "systemstat",
|
||||
}
|
||||
|
||||
function SystemStatWidget:onDispatcherRegisterActions()
|
||||
Dispatcher:registerAction("system_statistics", {category="none", event="ShowSysStatistics", title=_("System statistics"), device=true, separator=true})
|
||||
end
|
||||
|
||||
function SystemStatWidget:init()
|
||||
self:onDispatcherRegisterActions()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
@@ -268,6 +274,10 @@ function SystemStatWidget:addToMainMenu(menu_items)
|
||||
}
|
||||
end
|
||||
|
||||
function SystemStatWidget:onShowSysStatistics()
|
||||
SystemStat:showStatistics()
|
||||
end
|
||||
|
||||
function SystemStatWidget:onSuspend()
|
||||
SystemStat:onSuspend()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user