fix(color): quick menu may not show last selected icon correctly (#7555)
This commit is contained in:
@@ -228,6 +228,8 @@ class QuickSubMenu
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
QuickMenu* QuickMenu::instance = nullptr;
|
QuickMenu* QuickMenu::instance = nullptr;
|
||||||
|
QMPage QuickMenu::curPage = QM_NONE;
|
||||||
|
EdgeTxIcon QuickMenu::curIcon = EDGETX_ICONS_COUNT;
|
||||||
|
|
||||||
void QuickMenu::openQuickMenu()
|
void QuickMenu::openQuickMenu()
|
||||||
{
|
{
|
||||||
@@ -287,7 +289,7 @@ QuickMenu::QuickMenu() :
|
|||||||
for (int i = 0; qmTopItems[i].icon != EDGETX_ICONS_COUNT; i += 1) {
|
for (int i = 0; qmTopItems[i].icon != EDGETX_ICONS_COUNT; i += 1) {
|
||||||
if (qmTopItems[i].pageAction == QM_ACTION) {
|
if (qmTopItems[i].pageAction == QM_ACTION) {
|
||||||
mainMenu->addButton(qmTopItems[i].icon, STR_VAL(qmTopItems[i].qmTitle),
|
mainMenu->addButton(qmTopItems[i].icon, STR_VAL(qmTopItems[i].qmTitle),
|
||||||
[=]() { onSelect(true); qmTopItems[i].action(); }, qmTopItems[i].enabled);
|
[=]() { topMenuAction(i); }, qmTopItems[i].enabled);
|
||||||
#if VERSION_MAJOR > 2
|
#if VERSION_MAJOR > 2
|
||||||
} else {
|
} else {
|
||||||
auto sub = new QuickSubMenu(box, this, &qmTopItems[i]);
|
auto sub = new QuickSubMenu(box, this, &qmTopItems[i]);
|
||||||
@@ -371,26 +373,30 @@ void QuickMenu::selected()
|
|||||||
instance->onSelect(true);
|
instance->onSelect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickMenu::topMenuAction(int n)
|
||||||
|
{
|
||||||
|
selected();
|
||||||
|
setCurrentPage(qmTopItems[n].qmPage, qmTopItems[n].icon);
|
||||||
|
qmTopItems[n].action();
|
||||||
|
}
|
||||||
|
|
||||||
void QuickMenu::openPage(QMPage page)
|
void QuickMenu::openPage(QMPage page)
|
||||||
{
|
{
|
||||||
for (int i = FIRST_SEARCH_IDX; qmTopItems[i].icon != EDGETX_ICONS_COUNT; i += 1) {
|
for (int i = FIRST_SEARCH_IDX; qmTopItems[i].icon != EDGETX_ICONS_COUNT; i += 1) {
|
||||||
if (qmTopItems[i].pageAction == QM_ACTION) {
|
if (qmTopItems[i].pageAction == QM_ACTION) {
|
||||||
if (qmTopItems[i].qmPage == page) {
|
if (qmTopItems[i].qmPage == page) {
|
||||||
QuickMenu::selected();
|
topMenuAction(i);
|
||||||
setCurrentPage(page, qmTopItems[i].icon);
|
|
||||||
qmTopItems[i].action();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const PageDef* sub = qmTopItems[i].subMenuItems;
|
const PageDef* sub = qmTopItems[i].subMenuItems;
|
||||||
for (int j = 0, k = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) {
|
for (int j = 0, k = 0; sub[j].icon != EDGETX_ICONS_COUNT; j += 1) {
|
||||||
if (sub[j].qmPage == page) {
|
if (sub[j].qmPage == page) {
|
||||||
|
selected();
|
||||||
|
setCurrentPage(page, qmTopItems[i].icon);
|
||||||
if (sub[j].pageAction == PAGE_ACTION) {
|
if (sub[j].pageAction == PAGE_ACTION) {
|
||||||
QuickMenu::selected();
|
|
||||||
setCurrentPage(page, qmTopItems[i].icon);
|
|
||||||
sub[j].action();
|
sub[j].action();
|
||||||
} else {
|
} else {
|
||||||
QuickMenu::selected();
|
|
||||||
auto pg = new PageGroup(qmTopItems[i].icon, STR_VAL(qmTopItems[i].title), sub);
|
auto pg = new PageGroup(qmTopItems[i].icon, STR_VAL(qmTopItems[i].title), sub);
|
||||||
pg->setCurrentTab(k);
|
pg->setCurrentTab(k);
|
||||||
return;
|
return;
|
||||||
@@ -575,10 +581,8 @@ bool QuickMenu::setupFavorite(int favIdx, int favBtn)
|
|||||||
|
|
||||||
void QuickMenu::setCurrentPage(QMPage newPage, EdgeTxIcon newIcon)
|
void QuickMenu::setCurrentPage(QMPage newPage, EdgeTxIcon newIcon)
|
||||||
{
|
{
|
||||||
if (instance) {
|
curPage = newPage;
|
||||||
instance->curPage = newPage;
|
curIcon = newIcon;
|
||||||
instance->curIcon = newIcon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickMenu::focusMainMenu()
|
void QuickMenu::focusMainMenu()
|
||||||
|
|||||||
@@ -153,14 +153,14 @@ class QuickMenu : public NavWindow
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static QuickMenu* instance;
|
static QuickMenu* instance;
|
||||||
|
static QMPage curPage;
|
||||||
|
static EdgeTxIcon curIcon;
|
||||||
bool inSubMenu = false;
|
bool inSubMenu = false;
|
||||||
QuickMenuGroup* mainMenu = nullptr;
|
QuickMenuGroup* mainMenu = nullptr;
|
||||||
#if VERSION_MAJOR > 2
|
#if VERSION_MAJOR > 2
|
||||||
std::vector<QuickSubMenu*> subMenus;
|
std::vector<QuickSubMenu*> subMenus;
|
||||||
#endif
|
#endif
|
||||||
PageGroupBase* pageGroup = nullptr;
|
PageGroupBase* pageGroup = nullptr;
|
||||||
QMPage curPage = QM_NONE;
|
|
||||||
EdgeTxIcon curIcon = EDGETX_ICONS_COUNT;
|
|
||||||
|
|
||||||
void openQM(PageGroupBase* pageGroup, QMPage curPage);
|
void openQM(PageGroupBase* pageGroup, QMPage curPage);
|
||||||
void closeQM();
|
void closeQM();
|
||||||
@@ -170,6 +170,7 @@ class QuickMenu : public NavWindow
|
|||||||
void deleteLater() override;
|
void deleteLater() override;
|
||||||
|
|
||||||
static void selected();
|
static void selected();
|
||||||
|
static void topMenuAction(int n);
|
||||||
|
|
||||||
#if VERSION_MAJOR > 2
|
#if VERSION_MAJOR > 2
|
||||||
void updateFavorites();
|
void updateFavorites();
|
||||||
|
|||||||
Reference in New Issue
Block a user