fix: FlashDialog and popups
This commit is contained in:
committed by
Raphael Coeffic
parent
5a9fdb4eb5
commit
12ef9ced2d
@@ -161,6 +161,7 @@ add_definitions(-DLIBOPENUI)
|
|||||||
add_gui_src(fullscreen_dialog.cpp)
|
add_gui_src(fullscreen_dialog.cpp)
|
||||||
add_gui_src(message_dialog.cpp)
|
add_gui_src(message_dialog.cpp)
|
||||||
add_gui_src(confirm_dialog.cpp)
|
add_gui_src(confirm_dialog.cpp)
|
||||||
|
add_gui_src(popups.cpp)
|
||||||
add_gui_src(timeedit.cpp)
|
add_gui_src(timeedit.cpp)
|
||||||
add_gui_src(curve.cpp)
|
add_gui_src(curve.cpp)
|
||||||
add_gui_src(sourcechoice.cpp)
|
add_gui_src(sourcechoice.cpp)
|
||||||
|
|||||||
@@ -332,6 +332,12 @@ LvglWrapper::LvglWrapper()
|
|||||||
window->setActiveScreen();
|
window->setActiveScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LvglWrapper* LvglWrapper::instance()
|
||||||
|
{
|
||||||
|
if (!_instance) _instance = new LvglWrapper();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
void LvglWrapper::run()
|
void LvglWrapper::run()
|
||||||
{
|
{
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
@@ -341,3 +347,11 @@ void LvglWrapper::run()
|
|||||||
#endif
|
#endif
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LvglWrapper::pollInputs()
|
||||||
|
{
|
||||||
|
lv_indev_t* indev = nullptr;
|
||||||
|
while((indev = lv_indev_get_next(indev)) != nullptr) {
|
||||||
|
lv_indev_read_timer_cb(indev->driver->read_timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,22 +61,19 @@ class LvglWidgetFactory
|
|||||||
bool styleInitialized;
|
bool styleInitialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LvglWrapper {
|
class LvglWrapper
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
|
static LvglWrapper* instance();
|
||||||
|
|
||||||
|
void run();
|
||||||
|
void pollInputs();
|
||||||
|
|
||||||
|
private:
|
||||||
LvglWrapper();
|
LvglWrapper();
|
||||||
~LvglWrapper() {}
|
~LvglWrapper() {}
|
||||||
|
|
||||||
static LvglWrapper* instance()
|
static LvglWrapper *_instance;
|
||||||
{
|
|
||||||
if (!_instance)
|
|
||||||
_instance = new LvglWrapper();
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static LvglWrapper* _instance;
|
|
||||||
tmr10ms_t lastTick = 0;
|
tmr10ms_t lastTick = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) EdgeTX
|
||||||
|
*
|
||||||
|
* Based on code named
|
||||||
|
* opentx - https://github.com/opentx/opentx
|
||||||
|
* th9x - http://code.google.com/p/th9x
|
||||||
|
* er9x - http://code.google.com/p/er9x
|
||||||
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
|
*
|
||||||
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "popups.h"
|
||||||
|
#include "libopenui.h"
|
||||||
|
|
||||||
|
static MessageDialog * createPopupInformation(const char * message)
|
||||||
|
{
|
||||||
|
return new MessageDialog(MainWindow::instance(), "Message", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MessageDialog * createPopupWarning(const char * message)
|
||||||
|
{
|
||||||
|
return new MessageDialog(MainWindow::instance(), "Warning", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void POPUP_INFORMATION(const char * message)
|
||||||
|
{
|
||||||
|
auto popup = createPopupInformation(message);
|
||||||
|
while (popup->getParent()) {
|
||||||
|
WDG_RESET();
|
||||||
|
lv_refr_now(nullptr);
|
||||||
|
LvglWrapper::instance()->pollInputs();
|
||||||
|
RTOS_WAIT_MS(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void POPUP_WARNING(const char * message, const char * info)
|
||||||
|
{
|
||||||
|
auto popup = createPopupWarning(message);
|
||||||
|
if (info) {
|
||||||
|
popup->setInfoText(std::string(info));
|
||||||
|
}
|
||||||
|
while (popup->getParent()) {
|
||||||
|
WDG_RESET();
|
||||||
|
lv_refr_now(nullptr);
|
||||||
|
LvglWrapper::instance()->pollInputs();
|
||||||
|
RTOS_WAIT_MS(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,45 +19,11 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _POPUPS_H_
|
#pragma once
|
||||||
#define _POPUPS_H_
|
|
||||||
|
|
||||||
#include "libopenui.h"
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
typedef std::function<void(const char *, const char *, int, int)> ProgressHandler;
|
typedef std::function<void(const char *, const char *, int, int)> ProgressHandler;
|
||||||
|
|
||||||
inline MessageDialog * createPopupInformation(const char * message)
|
void POPUP_INFORMATION(const char * message);
|
||||||
{
|
void POPUP_WARNING(const char * message, const char * info = nullptr);
|
||||||
return new MessageDialog(MainWindow::instance(), "Message", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline MessageDialog * createPopupWarning(const char * message)
|
|
||||||
{
|
|
||||||
return new MessageDialog(MainWindow::instance(), "Warning", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void POPUP_INFORMATION(const char * message)
|
|
||||||
{
|
|
||||||
auto popup = createPopupInformation(message);
|
|
||||||
while (popup->getParent()) {
|
|
||||||
WDG_RESET();
|
|
||||||
MainWindow::instance()->run(false);
|
|
||||||
LvglWrapper::instance()->run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void POPUP_WARNING(const char * message, const char * info = nullptr)
|
|
||||||
{
|
|
||||||
auto popup = createPopupWarning(message);
|
|
||||||
if (info) {
|
|
||||||
popup->setInfoText(std::string(info));
|
|
||||||
}
|
|
||||||
while (popup->getParent()) {
|
|
||||||
WDG_RESET();
|
|
||||||
MainWindow::instance()->run(false);
|
|
||||||
LvglWrapper::instance()->run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _POPUPS_H_
|
|
||||||
|
|||||||
@@ -138,8 +138,7 @@ class FlashDialog: public FullScreenDialog
|
|||||||
int total) -> void {
|
int total) -> void {
|
||||||
setMessage(message);
|
setMessage(message);
|
||||||
progress.setValue(total > 0 ? count * 100 / total : 0);
|
progress.setValue(total > 0 ? count * 100 / total : 0);
|
||||||
MainWindow::instance()->run(false);
|
lv_refr_now(nullptr);
|
||||||
LvglWrapper::instance()->run();
|
|
||||||
});
|
});
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: c665709b51...78258004fe
Reference in New Issue
Block a user