diff --git a/lib/applications/src/app.cpp b/lib/applications/src/app.cpp index 3eb3621d..8a50687e 100644 --- a/lib/applications/src/app.cpp +++ b/lib/applications/src/app.cpp @@ -353,10 +353,6 @@ namespace AppManager { // Get the currently running app App* app = appStack.back(); - if (app->background) { - return; - } - // Kill the app app->kill(); } diff --git a/lib/lua/src/lua_file.cpp b/lib/lua/src/lua_file.cpp index 4284dc76..4e33ffca 100755 --- a/lib/lua/src/lua_file.cpp +++ b/lib/lua/src/lua_file.cpp @@ -617,7 +617,8 @@ void LuaFile::load() lua.set("COLOR_LIGHT_GREY", COLOR_LIGHT_GREY); lua.set_function("launch", sol::overload([&](std::string name, std::vector arg) - { + { + std::cerr << "launch is deprecated, use system.app:launch instead" << std::endl; try{ AppManager::get(name)->run(arg); } @@ -728,6 +729,53 @@ void LuaFile::load() app.set_function("quit", [&]() { m_commandQueue.push(QUIT); }); + + app.set_function("launch", sol::overload([&](std::string name, std::vector arg) + { + try{ + AppManager::get(name)->run(arg); + } + catch(std::runtime_error &e) { + std::cerr << "Erreur: " << e.what() << std::endl; + // Ajout message d'erreur + GuiManager &guiManager = GuiManager::getInstance(); + guiManager.showErrorMessage(e.what()); + } + + return true; }, + [&](std::string name) + { + try + { + AppManager::get(name)->run({}); + } + catch (std::runtime_error &e) + { + std::cerr << "Erreur: " << e.what() << std::endl; + // Ajout message d'erreur + GuiManager &guiManager = GuiManager::getInstance(); + guiManager.showErrorMessage(e.what()); + } + + return true; + })); + + app.set_function("stopApp", sol::overload([&](std::string name) + { + try{ + auto app = AppManager::get(name); + if(app->luaInstance != nullptr && app->luaInstance.get() != this) + app->kill(); + } + catch(std::runtime_error &e) { + std::cerr << "Erreur: " << e.what() << std::endl; + // Ajout message d'erreur + GuiManager &guiManager = GuiManager::getInstance(); + guiManager.showErrorMessage(e.what()); + } + + return true; } + )); } /** @@ -855,7 +903,7 @@ void LuaFile::wakeup(std::vector arg) void LuaFile::stop(std::vector arg) { const sol::protected_function func = lua.get("quit"); - ; + if (!func.valid()) return; @@ -871,7 +919,7 @@ void LuaFile::loop() { case QUIT: // Quit lua app OUTSIDE of lua - AppManager::quitApp(); + AppManager::get(this)->kill(); break; } diff --git a/src/main.cpp b/src/main.cpp index 7f69409b..bf7017ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -219,6 +219,11 @@ void setup() systemConfig.write(); } + if (!systemConfig.has("settings.sleeptime")) { + systemConfig.set("settings.sleeptime", 30000); + systemConfig.write(); + } + libsystem::log("settings.brightness: " + std::to_string(systemConfig.get("settings.brightness"))); graphics::setBrightness(systemConfig.get("settings.brightness")); diff --git a/storage/sys_apps/.oobe/app.lua b/storage/sys_apps/.oobe/app.lua index af677c39..a61f94b3 100644 --- a/storage/sys_apps/.oobe/app.lua +++ b/storage/sys_apps/.oobe/app.lua @@ -8,19 +8,19 @@ function run(arg) title:setFontSize(42) title = gui:label(win, 0, 210, 320, 40) - title:setText("Running on PaxOS 9") + title:setText("Utilise le PaxOS 9") title:setTextColor(100, 100, 100) title:setHorizontalAlignment(CENTER_ALIGNMENT) title:setFontSize(20) button = gui:button(win, 100, 380, 120, 40) button:setIcon("sys_apps/.oobe/resources/images/arrow_forward_ios_64px.png") - button:setText("Welcome") + button:setText("Bienvenu !") button:onClick(function () - paxo.system.config.set("oobe", true) - paxo.system.config.write() + system.config.set("oobe", true) + system.config.write() - paxo.app.quit() + system.app.quit() end) gui:setWindow(win) diff --git a/storage/sys_apps/settings/app.lua b/storage/sys_apps/settings/app.lua index 4430b0da..38de65c5 100644 --- a/storage/sys_apps/settings/app.lua +++ b/storage/sys_apps/settings/app.lua @@ -147,7 +147,22 @@ function systemSettings() textBrightness:setVerticalAlignment(CENTER_ALIGNMENT) textBrightness:setText("Luminosité") - local brightnessSlider = gui:slider(brightnessBox, 15, 53, 230, 10, 5, 255, system.config.getInt("settings.brightness")) + local brightnessSlider = gui:slider(brightnessBox, 15, 53, 230, 10, 5, 255, settings.getBrightness()) + brightnessSlider:onChange(function() + settings.setBrightness(brightnessSlider:getValue(), false) + end) + + local sleepTimeBox = createBox(win2, 100, 73) + local textsleepTime = gui:label(sleepTimeBox, 16, 0, 177, 55) + textsleepTime:setFontSize(24) + textsleepTime:setVerticalAlignment(CENTER_ALIGNMENT) + textsleepTime:setText("Veille: " .. int(settings.getStandBySleepTime()/1000) .. "s") + print("sleep time: " .. settings.getStandBySleepTime()) + local sleepTimeSlider = gui:slider(sleepTimeBox, 15, 53, 230, 10, 20, 120, int(settings.getStandBySleepTime()/1000)) + sleepTimeSlider:onChange(function() + settings.setStandBySleepTime(sleepTimeSlider:getValue()*1000, true) + textsleepTime:setText("Veille: " .. int(sleepTimeSlider:getValue()) .. "s") + end) gui:setWindow(win2) end diff --git a/storage/sys_apps/testbc/app.lua b/storage/sys_apps/testbc/app.lua index f5f412cb..51de30b0 100644 --- a/storage/sys_apps/testbc/app.lua +++ b/storage/sys_apps/testbc/app.lua @@ -1,17 +1,6 @@ function run() - print("run baground testbc app, no displayed: show conter to 10 and run settings app") - print(time) - -- local counter = 0 + print("this app in not in the background, will launch sub1 app for 5 seconds") - -- local function printCounter() - -- counter = counter + 1 - -- print("Counter: " .. counter .. " sec") - -- if(counter == 10) then - -- launch("settings") - -- end - -- end - - -- time:setInterval(printCounter, 1000) - - launch("testbc.sub1") + window = gui:window() + gui:setWindow(window) end \ No newline at end of file diff --git a/storage/sys_apps/testbc/sub/.sub1/app.lua b/storage/sys_apps/testbc/sub/.sub1/app.lua index 46ae75be..b72a1e2f 100644 --- a/storage/sys_apps/testbc/sub/.sub1/app.lua +++ b/storage/sys_apps/testbc/sub/.sub1/app.lua @@ -1,14 +1,6 @@ function run() - print("run sub1 app in background: will display counter2 to 10 then run the settings app") - local counter = 0 - - local function printCounter() - counter = counter + 1 - print("Counter 2: " .. counter .. " sec") - if(counter == 10) then - launch("settings") - end - end - - time:setInterval(printCounter, 1000) -end \ No newline at end of file + time:setTimeout(function() + launch("testbc") + system.app:quit() + end, 1000) +end diff --git a/storage/sys_apps/testbc/sub/.sub1/manifest.json b/storage/sys_apps/testbc/sub/.sub1/manifest.json index fba5d376..234d340e 100644 --- a/storage/sys_apps/testbc/sub/.sub1/manifest.json +++ b/storage/sys_apps/testbc/sub/.sub1/manifest.json @@ -4,6 +4,6 @@ "files", "time" ], - "background": true, - "autorun": false + "background": false, + "autorun": true } \ No newline at end of file diff --git a/storage/system/config.bfc b/storage/system/config.bfc index 164046c5..b093f136 100644 Binary files a/storage/system/config.bfc and b/storage/system/config.bfc differ